Skip to content

Commit

Permalink
Was deleted somehow during previous merge (@cheng)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chengjie8 authored and agile-josiah committed Oct 18, 2023
1 parent eca5fe2 commit ee26c61
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ private BieMessagePayload handleGenericRecord(ConsumerRecord<String, Object> 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(
Expand All @@ -73,6 +75,8 @@ private BieMessagePayload handleGenericRecord(ConsumerRecord<String, Object> 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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}

0 comments on commit ee26c61

Please sign in to comment.