From ee26c61429197be4b8895af9309d75af73fb4ac0 Mon Sep 17 00:00:00 2001 From: Cheng <89034346+chengjie8@users.noreply.github.com> Date: Tue, 10 Oct 2023 08:56:22 -0700 Subject: [PATCH] Was deleted somehow during previous merge (@cheng) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added migration script and code changes for action and actionResultNa… (#2069) * added migration script and code changes for action and actionResultName changes * added ActionName and ActionResultName to the builder method * added unit test for 2 added fields --- .../V1.3__BIE_Contention_Event_Add_Additional_Columns.sql | 3 +++ .../gov/va/vro/routes/xample/BieXampleRoutesTest.java | 8 +++++--- .../java/gov/va/vro/model/biekafka/BieMessagePayload.java | 2 ++ .../vro/model/biekafka/test/BieMessagePayloadFactory.java | 2 ++ .../va/vro/services/bie/service/kafka/KafkaConsumer.java | 4 ++++ .../va/vro/services/bie/service/BieRabbitServiceTest.java | 2 ++ 6 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 db-init/src/main/resources/database/migrations/V1.3__BIE_Contention_Event_Add_Additional_Columns.sql diff --git a/db-init/src/main/resources/database/migrations/V1.3__BIE_Contention_Event_Add_Additional_Columns.sql b/db-init/src/main/resources/database/migrations/V1.3__BIE_Contention_Event_Add_Additional_Columns.sql new file mode 100644 index 0000000000..6d16eb4e2a --- /dev/null +++ b/db-init/src/main/resources/database/migrations/V1.3__BIE_Contention_Event_Add_Additional_Columns.sql @@ -0,0 +1,3 @@ +ALTER TABLE "bie_contention_event" +ADD COLUMN "action_name" VARCHAR(255) DEFAULT NULL, +ADD COLUMN "action_result_name" VARCHAR(255) DEFAULT NULL; diff --git a/domain-xample/xample-workflows/src/test/java/gov/va/vro/routes/xample/BieXampleRoutesTest.java b/domain-xample/xample-workflows/src/test/java/gov/va/vro/routes/xample/BieXampleRoutesTest.java index 338ae9f107..153b5a3f34 100644 --- a/domain-xample/xample-workflows/src/test/java/gov/va/vro/routes/xample/BieXampleRoutesTest.java +++ b/domain-xample/xample-workflows/src/test/java/gov/va/vro/routes/xample/BieXampleRoutesTest.java @@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j; import org.apache.camel.RoutesBuilder; import org.apache.camel.builder.AdviceWith; -import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -71,7 +70,10 @@ void testSaveContentionEventRoute() { assertThat(response.getContentionId()).isEqualTo(testItem.getContentionId()); assertThat(response.getContentionTypeCode()).isEqualTo(testItem.getContentionTypeCode()); assertThat(response.getDiagnosticTypeCode()).isEqualTo(testItem.getDiagnosticTypeCode()); - MockEndpoint.assertIsSatisfied(context); + assertThat(response.getActionName()).isEqualTo(testItem.getActionName()); + assertThat(response.getActionResultName()).isEqualTo(testItem.getActionResultName()); + + assertMockEndpointsSatisfied(); } @Test @@ -87,6 +89,6 @@ void testMainRouteOnException() { assertThat(response.getStatus()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR.value()); assertThat(response.getStatusMessage()).isEqualTo(exception.toString()); - MockEndpoint.assertIsSatisfied(context); + assertMockEndpointsSatisfied(); } } diff --git a/shared/lib-bie-kafka/src/main/java/gov/va/vro/model/biekafka/BieMessagePayload.java b/shared/lib-bie-kafka/src/main/java/gov/va/vro/model/biekafka/BieMessagePayload.java index 307de9bfb3..34e65a863c 100644 --- a/shared/lib-bie-kafka/src/main/java/gov/va/vro/model/biekafka/BieMessagePayload.java +++ b/shared/lib-bie-kafka/src/main/java/gov/va/vro/model/biekafka/BieMessagePayload.java @@ -18,6 +18,8 @@ public class BieMessagePayload { private String contentionTypeCode; private String contentionClassificationName; private String diagnosticTypeCode; + private String actionName; + private String actionResultName; private long notifiedAt; private long occurredAt; } diff --git a/shared/lib-bie-kafka/src/main/java/gov/va/vro/model/biekafka/test/BieMessagePayloadFactory.java b/shared/lib-bie-kafka/src/main/java/gov/va/vro/model/biekafka/test/BieMessagePayloadFactory.java index 837b066852..82e49434b5 100644 --- a/shared/lib-bie-kafka/src/main/java/gov/va/vro/model/biekafka/test/BieMessagePayloadFactory.java +++ b/shared/lib-bie-kafka/src/main/java/gov/va/vro/model/biekafka/test/BieMessagePayloadFactory.java @@ -20,6 +20,8 @@ public static BieMessagePayload create() { .diagnosticTypeCode(faker.lorem().characters(10)) .occurredAt(faker.date().past(60, TimeUnit.DAYS).getTime()) .notifiedAt(faker.date().past(60, TimeUnit.DAYS).getTime()) + .actionName(faker.lorem().characters(10)) + .actionResultName(faker.lorem().characters(10)) .status(200) .build(); } diff --git a/svc-bie-kafka/src/main/java/gov/va/vro/services/bie/service/kafka/KafkaConsumer.java b/svc-bie-kafka/src/main/java/gov/va/vro/services/bie/service/kafka/KafkaConsumer.java index a5cbdaf4a0..e1ccf1ee95 100644 --- a/svc-bie-kafka/src/main/java/gov/va/vro/services/bie/service/kafka/KafkaConsumer.java +++ b/svc-bie-kafka/src/main/java/gov/va/vro/services/bie/service/kafka/KafkaConsumer.java @@ -62,6 +62,8 @@ private BieMessagePayload handleGenericRecord(ConsumerRecord rec String KEY_CONTENTION_ID = "ContentionId"; String KEY_CONTENTION_TYPE_CODE = "ContentionTypeCode"; String KEY_EVENT_TIME = "EventTime"; + String ACTION_NAME = "ActionName"; + String ACTION_RESULT_NAME = "ActionResultName"; return BieMessagePayload.builder() .eventType( @@ -73,6 +75,8 @@ private BieMessagePayload handleGenericRecord(ConsumerRecord rec .diagnosticTypeCode((String) messageValue.get(KEY_DIAGNOSTIC_TYPE_CODE)) .occurredAt((Long) messageValue.get(KEY_EVENT_TIME)) .notifiedAt(record.timestamp()) + .actionName((String) messageValue.get(ACTION_NAME)) + .actionResultName((String) messageValue.get(ACTION_RESULT_NAME)) .status(200) .build(); } diff --git a/svc-bie-kafka/src/test/java/gov/va/vro/services/bie/service/BieRabbitServiceTest.java b/svc-bie-kafka/src/test/java/gov/va/vro/services/bie/service/BieRabbitServiceTest.java index 6addaa1d42..c5d7381818 100644 --- a/svc-bie-kafka/src/test/java/gov/va/vro/services/bie/service/BieRabbitServiceTest.java +++ b/svc-bie-kafka/src/test/java/gov/va/vro/services/bie/service/BieRabbitServiceTest.java @@ -50,6 +50,8 @@ void shouldConvertAndSendBiePayload() { .isEqualTo(payload.getContentionClassificationName()); assertThat(value.getDiagnosticTypeCode()).isEqualTo(payload.getDiagnosticTypeCode()); assertThat(value.getNotifiedAt()).isEqualTo(payload.getNotifiedAt()); + assertThat(value.getActionName()).isEqualTo(payload.getActionName()); + assertThat(value.getActionResultName()).isEqualTo(payload.getActionResultName()); } } }