Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed references to shared project #67

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .run/Run Application (docker-dev).run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<env name="firestore.project-id" value="our-project" />
<env name="FIRESTORE_EMULATOR_HOST" value="localhost:8542" />
<env name="spring.cloud.gcp.pubsub.emulator-host" value="localhost:8538" />
<env name="spring.cloud.gcp.pubsub.project-id" value="shared-project" />
<env name="spring.cloud.gcp.pubsub.project-id" value="our-project" />
</envs>
<module name="ssdc-rh-service" />
<option name="SPRING_BOOT_MAIN_CLASS" value="uk.gov.ons.ssdc.rhservice.Application" />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ EXCEPTIONMANAGER_CONNECTION_PORT=8666
FIRESTORE_EMULATOR_HOST=localhost:8542
firestore.project-id=our-project
spring.cloud.gcp.pubsub.emulator-host=localhost:8538
spring.cloud.gcp.pubsub.project-id=shared-project
spring.cloud.gcp.pubsub.project-id=our-project
```
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public class MessageConsumerConfig {
private final ManagedMessageRecoverer managedMessageRecoverer;
private final PubSubTemplate pubSubTemplate;

@Value("${queueconfig.shared-pubsub-project}")
private String sharedPubsubProject;
@Value("${spring.cloud.gcp.pubsub.project-id}")
private String pubsubProject;

@Value("${queueconfig.case-update-subscription}")
private String caseUpdateSubscription;
Expand Down Expand Up @@ -58,23 +58,23 @@ public MessageChannel collectionExerciseUpdateChannel() {
public PubSubInboundChannelAdapter newCaseInbound(
@Qualifier("caseUpdateInputChannel") MessageChannel channel) {
String subscription =
toProjectSubscriptionName(caseUpdateSubscription, sharedPubsubProject).toString();
toProjectSubscriptionName(caseUpdateSubscription, pubsubProject).toString();
return makeAdapter(channel, subscription);
}

@Bean
public PubSubInboundChannelAdapter newUacInbound(
@Qualifier("uacUpdateInputChannel") MessageChannel channel) {
String subscription =
toProjectSubscriptionName(uacUpdateSubscription, sharedPubsubProject).toString();
toProjectSubscriptionName(uacUpdateSubscription, pubsubProject).toString();
return makeAdapter(channel, subscription);
}

@Bean
public PubSubInboundChannelAdapter newCollectionExerciseInbound(
@Qualifier("collectionExerciseUpdateChannel") MessageChannel channel) {
String subscription =
toProjectSubscriptionName(collectionExerciseSubscription, sharedPubsubProject).toString();
toProjectSubscriptionName(collectionExerciseSubscription, pubsubProject).toString();
return makeAdapter(channel, subscription);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ public void buildAndSendEqLaunchEvent(Map<String, Object> payload, String qid) {
eqLaunchEvent.setPayload(payloadDTO);

String messageJson = convertObjectToJson(eqLaunchEvent);
pubsubHelper.sendMessageToSharedProject(eqLaunchTopic, messageJson);
pubsubHelper.sendMessageToPubsubProject(eqLaunchTopic, messageJson);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public PubsubHelper(PubSubTemplate pubSubTemplate) {
this.pubSubTemplate = pubSubTemplate;
}

@Value("${queueconfig.shared-pubsub-project}")
private String sharedPubsubProject;
@Value("${spring.cloud.gcp.pubsub.project-id}")
private String pubsubProject;

public void sendMessageToSharedProject(String topicName, Object message) {
String fullyQualifiedTopic = toProjectTopicName(topicName, sharedPubsubProject).toString();
public void sendMessageToPubsubProject(String topicName, Object message) {
String fullyQualifiedTopic = toProjectTopicName(topicName, pubsubProject).toString();
sendMessage(fullyQualifiedTopic, message);
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ queueconfig:
uac-update-subscription: event_uac-update_rh
collection-exercise-update-subscription: event_collection-exercise-update_rh
eq-launch-topic: event_eq-launch
shared-pubsub-project: shared-project


cloud-storage:
case-schema-name: case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void testEqLaunchUrlSuccessfullyReturned()
String uacHash = RandomStringUtils.randomAlphabetic(10);

try (QueueSpy<EventDTO> outboundCaseQueueSpy =
pubsubTestHelper.sharedProjectListen(OUTBOUND_EQ_LAUNCH_SUBSCRIPTION, EventDTO.class)) {
pubsubTestHelper.pubsubProjectListen(OUTBOUND_EQ_LAUNCH_SUBSCRIPTION, EventDTO.class)) {
CaseUpdateDTO caseUpdateDTO = new CaseUpdateDTO();
caseUpdateDTO.setCaseId(CASE_ID);
caseUpdateDTO.setCollectionExerciseId(COLLEX_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void testCaseUpdateReceived() throws CaseNotFoundException {
event.setPayload(payloadDTO);

// WHEN
pubsubTestHelper.sendMessageToSharedProject(caseUpdateTopic, event);
pubsubTestHelper.sendMessageToPubsubProject(caseUpdateTopic, event);

// THEN
Optional<CaseUpdateDTO> cazeOpt = fireStorePoller.getCaseById(caseUpdateDTO.getCaseId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void testCollectionExerciseUpdateReceived() throws CollectionExerciseNotFoundExc
event.setPayload(payloadDTO);

// WHEN
pubsubTestHelper.sendMessageToSharedProject(collectionExerciseTopic, event);
pubsubTestHelper.sendMessageToPubsubProject(collectionExerciseTopic, event);

// THEN
Optional<CollectionExerciseUpdateDTO> collexOpt =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void testMessageSent() throws JsonProcessingException {
underTest.buildAndSendEqLaunchEvent(payload, TEST_QID);

ArgumentCaptor<String> eventArgCaptor = ArgumentCaptor.forClass(String.class);
verify(pubsubHelper).sendMessageToSharedProject(eq(TEST_TOPIC), eventArgCaptor.capture());
verify(pubsubHelper).sendMessageToPubsubProject(eq(TEST_TOPIC), eventArgCaptor.capture());

EventDTO eventDTO =
ObjectMapperFactory.objectMapper().readValue(eventArgCaptor.getValue(), EventDTO.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void testUacUpdateReceivedWithNoELaunchDataSettings() throws UacNotFoundExceptio
EventDTO eventDTO = new EventDTO(null, payloadDTO);

// WHEN
pubsubTestHelper.sendMessageToSharedProject(uacUpdateTopic, eventDTO);
pubsubTestHelper.sendMessageToPubsubProject(uacUpdateTopic, eventDTO);

// THEN
Optional<UacUpdateDTO> uacOpt = fireStorePoller.getUacByHash(uacUpdateDTO.getUacHash(), true);
Expand Down Expand Up @@ -133,7 +133,7 @@ void testUacUpdateReceivedWithEqLaunchSettingsCollex() throws UacNotFoundExcepti
event.setPayload(payloadDTO);

// WHEN
pubsubTestHelper.sendMessageToSharedProject(uacUpdateTopic, event);
pubsubTestHelper.sendMessageToPubsubProject(uacUpdateTopic, event);

// THEN
Optional<UacUpdateDTO> uacOpt = fireStorePoller.getUacByHash(uacUpdateDTO.getUacHash(), true);
Expand Down Expand Up @@ -205,7 +205,7 @@ void testInactiveUACBlanksLaunchSettings() throws UacNotFoundException {
event.setPayload(payloadDTO);

// WHEN
pubsubTestHelper.sendMessageToSharedProject(uacUpdateTopic, event);
pubsubTestHelper.sendMessageToPubsubProject(uacUpdateTopic, event);

// THEN
Optional<UacUpdateDTO> uacOpt = fireStorePoller.getUacByHash(oldUacDTO.getUacHash(), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public class PubsubTestHelper {

@Autowired private GcpPubSubProperties gcpPubSubProperties;

@Value("${queueconfig.shared-pubsub-project}")
private String sharedPubsubProject;
@Value("${spring.cloud.gcp.pubsub.project-id}")
private String pubsubProject;

private static final ObjectMapper objectMapper = ObjectMapperFactory.objectMapper();

public void sendMessageToSharedProject(String topicName, Object message) {
String fullyQualifiedTopic = toProjectTopicName(topicName, sharedPubsubProject).toString();
public void sendMessageToPubsubProject(String topicName, Object message) {
String fullyQualifiedTopic = toProjectTopicName(topicName, pubsubProject).toString();
sendMessage(fullyQualifiedTopic, message);
}

Expand All @@ -60,9 +60,9 @@ public void sendMessage(String topicName, Object message) {
}
}

public <T> QueueSpy sharedProjectListen(String subscription, Class<T> contentClass) {
public <T> QueueSpy pubsubProjectListen(String subscription, Class<T> contentClass) {
String fullyQualifiedSubscription =
toProjectSubscriptionName(subscription, sharedPubsubProject).toString();
toProjectSubscriptionName(subscription, pubsubProject).toString();
return listen(fullyQualifiedSubscription, contentClass);
}

Expand Down
1 change: 0 additions & 1 deletion src/test/resources/application-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ firestore:
emulator-host: localhost:18542

queueconfig:
shared-pubsub-project: shared-project
case-update-topic: event_case-update
uac-update-topic: event_uac-update
collection-exercise-update-topic: event_collection-exercise-update
Expand Down
18 changes: 9 additions & 9 deletions src/test/resources/setup_pubsub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
# Wait for pubsub-emulator to come up
bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' '$PUBSUB_SETUP_HOST')" != "200" ]]; do sleep 1; done'

curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/shared-project/topics/event_uac-update
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/shared-project/subscriptions/event_uac-update_rh -H 'Content-Type: application/json' -d '{"topic": "projects/shared-project/topics/event_uac-update"}'
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/our-project/topics/event_uac-update
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/our-project/subscriptions/event_uac-update_rh -H 'Content-Type: application/json' -d '{"topic": "projects/our-project/topics/event_uac-update"}'

curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/shared-project/topics/event_case-update
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/shared-project/subscriptions/event_case-update_rh -H 'Content-Type: application/json' -d '{"topic": "projects/shared-project/topics/event_case-update"}'
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/our-project/topics/event_case-update
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/our-project/subscriptions/event_case-update_rh -H 'Content-Type: application/json' -d '{"topic": "projects/our-project/topics/event_case-update"}'

curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/shared-project/topics/event_collection-exercise-update
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/shared-project/subscriptions/event_collection-exercise-update_rh -H 'Content-Type: application/json' -d '{"topic": "projects/shared-project/topics/event_collection-exercise-update"}'
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/our-project/topics/event_collection-exercise-update
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/our-project/subscriptions/event_collection-exercise-update_rh -H 'Content-Type: application/json' -d '{"topic": "projects/our-project/topics/event_collection-exercise-update"}'

curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/shared-project/topics/event_survey-update
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/our-project/topics/event_survey-update

curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/shared-project/topics/event_eq-launch
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/shared-project/subscriptions/event_eq-launch -H 'Content-Type: application/json' -d '{"topic": "projects/shared-project/topics/event_eq-launch"}'
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/our-project/topics/event_eq-launch
curl -X PUT http://$PUBSUB_SETUP_HOST/v1/projects/our-project/subscriptions/event_eq-launch -H 'Content-Type: application/json' -d '{"topic": "projects/our-project/topics/event_eq-launch"}'