Commit c205f793 authored by SGupta79's avatar SGupta79
Browse files

Reset with master and add customMetric implementation

parent c7f760fc
......@@ -14,6 +14,7 @@
<properties>
<osdu.corelibazure.version>0.0.51</osdu.corelibazure.version>
<osdu.os-wks-core.version>0.6.0-SNAPSHOT</osdu.os-wks-core.version>
<azure.applicationinsights.version>2.6.1</azure.applicationinsights.version>
</properties>
<dependencyManagement>
<dependencies>
......@@ -32,6 +33,11 @@
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-active-directory-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>applicationinsights-web-auto</artifactId>
<version>${azure.applicationinsights.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
......
package org.opengroup.osdu.wks.config;
package org.opengroup.osdu.wks.provider.azure.config;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.springframework.context.annotation.Primary;
......
......@@ -3,16 +3,14 @@ package org.opengroup.osdu.wks.provider.azure.pubsub;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import com.microsoft.azure.servicebus.IMessage;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.wks.config.ThreadDpsHeaders;
import org.opengroup.osdu.wks.config.ThreadJaxRsDpsLog;
import org.opengroup.osdu.wks.config.ThreadScopeContextHolder;
import org.opengroup.osdu.wks.exceptions.ApplicationException;
import org.opengroup.osdu.wks.exceptions.BadRequestException;
import org.opengroup.osdu.wks.logging.SliLoggerPayload;
import org.opengroup.osdu.wks.model.RawRecordDetails;
import org.opengroup.osdu.wks.provider.azure.config.ThreadDpsHeaders;
import org.opengroup.osdu.wks.provider.azure.utils.AppInsightsMetric;
import org.opengroup.osdu.wks.provider.azure.utils.MDCContextMap;
import org.opengroup.osdu.wks.service.WKSService;
import org.slf4j.Logger;
......@@ -30,7 +28,7 @@ public class ProcessWKSTransform {
private final static Logger LOGGER = LoggerFactory.getLogger(ProcessWKSTransform.class);
private static final String DATA = "data";
private static final String ID = "id";
private static final String SLI_LOG = "sli.log";
private static final String METRIC_NAME = "WKS-availability";
@Autowired
private WKSService wKSService;
......@@ -41,16 +39,10 @@ public class ProcessWKSTransform {
@Autowired
private ThreadDpsHeaders dpsHeaders;
@Autowired
private ThreadJaxRsDpsLog log;
public void initiateWksTransformation(IMessage message) {
String dataPartitionId = null;
String correlationId = null;
boolean transformationSucceeded = false;
AppInsightsMetric appInsightsMetric = new AppInsightsMetric();
try {
String messageBody = new String(message.getMessageBody().getBinaryData().get(0), UTF_8);
......@@ -60,8 +52,8 @@ public class ProcessWKSTransform {
String messageId = jsonRoot.getAsJsonObject().get(ID).getAsString();
message.setMessageId(messageId);
dataPartitionId = messageData.getAsJsonObject().get(DpsHeaders.DATA_PARTITION_ID).getAsString();
correlationId = messageData.getAsJsonObject().get(DpsHeaders.CORRELATION_ID).getAsString();
String dataPartitionId = messageData.getAsJsonObject().get(DpsHeaders.DATA_PARTITION_ID).getAsString();
String correlationId = messageData.getAsJsonObject().get(DpsHeaders.CORRELATION_ID).getAsString();
MDC.setContextMap(mdcContextMap.getContextMap(correlationId, dataPartitionId));
dpsHeaders.setThreadContext(dataPartitionId, correlationId);
......@@ -75,32 +67,30 @@ public class ProcessWKSTransform {
wKSService.transform(rawRecordDetails, dataPartitionId, correlationId);
LOGGER.info("Transformation completed for message with id: {}", message.getMessageId());
// populate customMetric with 1 as transformation completed for records
appInsightsMetric.write(METRIC_NAME, 1);
transformationSucceeded = true;
} catch (BadRequestException e) {
LOGGER.warn("Bad Request Reason: {}, pubsub message id: {}", e.getErrorMsg(), message.getMessageId(), e);
log.info(SLI_LOG, SliLoggerPayload.builder().status(false).messageId(message.getMessageId())
.statusCode(HttpStatus.BAD_REQUEST.value()).build().toString());
/*
* In case of 4xx populate customMetric with 1 as transformation failed because
* of user inputs like raw record not present, data Partition id is blank,
* correlation id is blank *
*/
appInsightsMetric.write(METRIC_NAME, 1);
LOGGER.warn("Bad Request Reason: {}, pubsub message id: {}", e.getErrorMsg(), message.getMessageId(), e);
} catch (ApplicationException e) {
// In case of 5xx populate customMetric with 1 as transformation failed.
appInsightsMetric.write(METRIC_NAME, 0);
LOGGER.warn("Application Error Reason: {}, pubsub message id: {}", e.getErrorMsg(), message.getMessageId(),
e);
log.info(SLI_LOG, SliLoggerPayload.builder().status(false).messageId(message.getMessageId())
.statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()).build().toString());
} catch (NullPointerException e) {
LOGGER.error("Invalid format for message with id: {}", message.getMessageId(), e);
log.info(SLI_LOG, SliLoggerPayload.builder().status(false).messageId(message.getMessageId())
.statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()).build().toString());
} catch (JsonSyntaxException e) {
LOGGER.error("Error occurred in payload parsing with id: {}", message.getMessageId(), e);
log.info(SLI_LOG, SliLoggerPayload.builder().status(false).messageId(message.getMessageId())
.statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()).build().toString());
appInsightsMetric.write(METRIC_NAME, 0);
LOGGER.warn("Invalid format for message with id: {}", message.getMessageId(), e);
} catch (Exception e) {
LOGGER.error("Exception encountered processing the message with id: {}", message.getMessageId(), e);
log.info(SLI_LOG, SliLoggerPayload.builder().status(false).messageId(message.getMessageId())
.statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()).build().toString());
appInsightsMetric.write(METRIC_NAME, 0);
LOGGER.warn("Exception encountered processing the message with id: {}", message.getMessageId(), e);
}
if (!transformationSucceeded) {
......
package org.opengroup.osdu.wks.provider.azure.utils;
import com.microsoft.applicationinsights.*;
import com.microsoft.applicationinsights.telemetry.MetricTelemetry;
import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* AppInsightsMetric allows putting data in customMetric table of appInsights for creating SLO availability dashboard.
*
*/
public class AppInsightsMetric {
private final static Logger LOGGER = LoggerFactory.getLogger(AppInsightsMetric.class);
private final TelemetryClient client;
public AppInsightsMetric() {
client = new TelemetryClient();
}
public void write(String name, int pass) {
LOGGER.info("AppInsightsMetric Name: {} Value {}", name, pass);
Date date = new Date(System.currentTimeMillis());
MetricTelemetry sample = new MetricTelemetry();
sample.setName(name);
sample.setValue(pass);
sample.setTimestamp(date);
client.trackMetric(sample);
client.flush();
}
}
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings" schemaVersion="2014-05-30">
<!-- HTTP request component (not required for bare API) -->
<TelemetryModules>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebRequestTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebSessionTrackingTelemetryModule"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.modules.WebUserTrackingTelemetryModule"/>
</TelemetryModules>
<!-- Events correlation (not required for bare API) -->
<!-- These initializers add context data to each event -->
<TelemetryInitializers>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationIdTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebOperationNameTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebSessionTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserTelemetryInitializer"/>
<Add type="com.microsoft.applicationinsights.web.extensibility.initializers.WebUserAgentTelemetryInitializer"/>
</TelemetryInitializers>
</ApplicationInsights>
\ No newline at end of file
......@@ -23,14 +23,12 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opengroup.osdu.wks.config.ThreadDpsHeaders;
import org.opengroup.osdu.wks.config.ThreadJaxRsDpsLog;
import org.opengroup.osdu.wks.exceptions.ApplicationException;
import org.opengroup.osdu.wks.exceptions.BadRequestException;
import org.opengroup.osdu.wks.model.RawRecordDetails;
import org.opengroup.osdu.wks.provider.azure.config.ThreadDpsHeaders;
import org.opengroup.osdu.wks.provider.azure.utils.MDCContextMap;
import org.opengroup.osdu.wks.service.WKSService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Collections;
......@@ -67,10 +65,6 @@ public class ProcessWKSTransformTest {
@Spy
private ThreadDpsHeaders dpsHeaders;
@Mock
private ThreadJaxRsDpsLog log;
@BeforeEach
public void init() {
......@@ -86,10 +80,7 @@ public class ProcessWKSTransformTest {
processWKSTransform.initiateWksTransformation(message);
verify(message, times(1)).getMessageBody();
verify(message, times(3)).getMessageId();
verify(message, times(2)).getMessageId();
}
@Test
......@@ -101,7 +92,7 @@ public class ProcessWKSTransformTest {
verify(mdcContextMap, times(1)).getContextMap(correlationId, dataPartitionId);
verify(message, times(1)).getMessageBody();
verify(message, times(3)).getMessageId();
verify(message, times(2)).getMessageId();
verify(message, times(1)).setMessageId(messageId);
}
......@@ -116,7 +107,7 @@ public class ProcessWKSTransformTest {
verify(mdcContextMap, times(1)).getContextMap(correlationId, dataPartitionId);
verify(message, times(1)).getMessageBody();
verify(message, times(4)).getMessageId();
verify(message, times(3)).getMessageId();
verify(message, times(1)).setMessageId(messageId);
}
......
package org.opengroup.osdu.wks.provider.azure.util;
import static org.hamcrest.CoreMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.ArgumentMatchers.any;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.opengroup.osdu.wks.provider.azure.utils.AppInsightsMetric;
import com.microsoft.applicationinsights.TelemetryClient;
@ExtendWith(MockitoExtension.class)
public class AppInsightsMetricTest {
@Mock
TelemetryClient mockTelemetryClient;
@Before()
public void setUp() throws Exception {
mockTelemetryClient = mock(TelemetryClient.class);
}
@Test
public void writeTest() {
AppInsightsMetric appInsightsMetric = spy(AppInsightsMetric.class);
appInsightsMetric.write("test-name", 1);
}
}
package org.opengroup.osdu.wks.config;
import org.opengroup.osdu.core.common.logging.DefaultLogger;
import org.opengroup.osdu.core.common.logging.ILogger;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.springframework.context.annotation.Primary;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;
@Component
@Primary
@Scope(value = "ThreadScope", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class ThreadJaxRsDpsLog extends JaxRsDpsLog {
public ThreadJaxRsDpsLog(ILogger log, ThreadDpsHeaders headers) {
super(new DefaultLogger(), headers);
}
}
\ No newline at end of file
package org.opengroup.osdu.wks.logging;
import lombok.Builder;
import lombok.Data;
import lombok.ToString;
@Data
@Builder
@ToString
public class SliLoggerPayload {
private String recordId;
private int statusCode;
private Boolean status;
private String dataPartitionId;
private String correlationId;
private String messageId;
}
......@@ -6,16 +6,11 @@ import java.util.*;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.opengroup.osdu.wks.config.RequestIdentity;
import org.opengroup.osdu.wks.config.ThreadJaxRsDpsLog;
import org.opengroup.osdu.wks.config.ThreadScopeContextHolder;
import org.opengroup.osdu.wks.constants.Constants;
import org.opengroup.osdu.wks.exceptions.ApplicationException;
import org.opengroup.osdu.wks.exceptions.BadRequestException;
import org.opengroup.osdu.wks.logging.SliLoggerPayload;
import org.opengroup.osdu.wks.exceptions.NotFoundException;
import org.opengroup.osdu.wks.model.RawRecordDetails;
import org.opengroup.osdu.wks.model.RelationshipStatus;
import org.opengroup.osdu.wks.model.TransformRequest;
......@@ -26,7 +21,6 @@ import org.opengroup.osdu.wks.util.WksTransformator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.datatree.Tree;
......@@ -40,7 +34,6 @@ public class WKSServiceImpl implements WKSService {
private static final String CREATE = "create";
private static final String ID = "id";
private static final String KIND = "kind";
private static final String SLI_LOG = "sli.log";
@Autowired
private MappingService mappingService;
......@@ -57,9 +50,6 @@ public class WKSServiceImpl implements WKSService {
@Autowired
private StatusStoreService statusStoreService;
@Autowired
private ThreadJaxRsDpsLog log;
/**
* This method applies the WKS transformation on the valid raw records
*
......@@ -78,9 +68,8 @@ public class WKSServiceImpl implements WKSService {
RawRecordDetails[] rawRecordsDetailsForTransformation = findValidRawRecordsDetailsForTransformation(
rawRecordsDetails);
if (rawRecordsDetailsForTransformation.length > 0) {
Map<String, List<MappingDefinition>> mappingsMap = retrieveMappingsMap(
rawRecordsDetailsForTransformation);
if(rawRecordsDetailsForTransformation.length > 0) {
Map<String, List<MappingDefinition>> mappingsMap = retrieveMappingsMap(rawRecordsDetailsForTransformation);
transformRecords(rawRecordsDetailsForTransformation, mappingsMap, dataPartitionId, correlationId);
}
} finally {
......@@ -104,7 +93,8 @@ public class WKSServiceImpl implements WKSService {
}
if (invalidOpCodeCount > 0) {
LOGGER.info(Constants.NOT_CREATE_OR_UPDATE_OPERATION, invalidOpCodeCount, rawRecordsDetails.length);
LOGGER.info(Constants.NOT_CREATE_OR_UPDATE_OPERATION, invalidOpCodeCount,
rawRecordsDetails.length);
}
if (invalidSourceCount > 0) {
......@@ -114,9 +104,9 @@ public class WKSServiceImpl implements WKSService {
return rawRecordsDetailsList.toArray(new RawRecordDetails[0]);
}
private void transformRecords(RawRecordDetails[] rawRecordsDetails,
Map<String, List<MappingDefinition>> mappingsMap, String dataPartitionId, String correlationId)
throws ApplicationException, BadRequestException {
private void transformRecords(RawRecordDetails[] rawRecordsDetails, Map<String, List<MappingDefinition>> mappingsMap,
String dataPartitionId, String correlationId) throws ApplicationException, BadRequestException {
List<Tree> wksRecordTreeList = new ArrayList<>();
List<RelationshipStatus> relationshipStatusList = new ArrayList<>();
for (RawRecordDetails rawRecord : rawRecordsDetails) {
......@@ -126,7 +116,7 @@ public class WKSServiceImpl implements WKSService {
LOGGER.info(Constants.TRANSFORMATION_STARTED, rawRecord.getId(), mappingsList.size());
Tree rawRecordTree = retrieveRawRecordTree(rawRecord);
for (MappingDefinition mappings : mappingsList) {
for (MappingDefinition mappings: mappingsList) {
try {
TransformRequest transformRequest = new TransformRequest(rawRecordTree, mappings);
......@@ -142,33 +132,23 @@ public class WKSServiceImpl implements WKSService {
LOGGER.info(Constants.TRANFORMATION_SUCCESSFUL, rawRecord.getId(),
wksRecordTree.get(ID).asString(), wksRecordTree.get(KIND));
log.info(SLI_LOG, SliLoggerPayload.builder().status(true).recordId(rawRecord.getId())
.statusCode(HttpStatus.OK.value()).build().toString());
} catch (ApplicationException e) {
LOGGER.warn(Constants.TRANSFORMATION_FAILED_FOR_GIVEN_WKS_KIND, rawRecord.getId(),
e.getErrorMsg(), e);
log.info(SLI_LOG, SliLoggerPayload.builder().status(false).recordId(rawRecord.getId())
.statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()).build().toString());
} catch (Exception e) {
LOGGER.warn(Constants.TRANSFORMATION_FAILED_FOR_GIVEN_WKS_KIND, rawRecord.getId(),
mappings.getMappingInfo().getTargetSchemaKind(), e.getMessage(), e);
log.info(SLI_LOG, SliLoggerPayload.builder().status(false).recordId(rawRecord.getId())
.statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()).build().toString());
}
catch (ApplicationException e) {
LOGGER.warn(Constants.TRANSFORMATION_FAILED_FOR_GIVEN_WKS_KIND, rawRecord.getId(), e.getErrorMsg(), e);
} catch (NotFoundException e) {
e.printStackTrace();
}
catch (Exception e) {
LOGGER.warn(Constants.TRANSFORMATION_FAILED_FOR_GIVEN_WKS_KIND, rawRecord.getId(), mappings.getMappingInfo().getTargetSchemaKind(), e.getMessage(), e);
}
}
} catch (ApplicationException e) {
LOGGER.warn(Constants.TRANFORMATION_FAILED, rawRecord.getId(), e.getErrorMsg(), e);
log.info(SLI_LOG, SliLoggerPayload.builder().status(false).recordId(rawRecord.getId())
.statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()).build().toString());
} catch (Exception e) {
}
catch (Exception e) {
LOGGER.warn(Constants.TRANFORMATION_FAILED, rawRecord.getId(), e.getMessage(), e);
log.info(SLI_LOG, SliLoggerPayload.builder().status(false).recordId(rawRecord.getId())
.statusCode(HttpStatus.INTERNAL_SERVER_ERROR.value()).build().toString());
}
}
......@@ -176,7 +156,7 @@ public class WKSServiceImpl implements WKSService {
saveAllWksRecords(wksRecordTreeList, dataPartitionId, correlationId);
LOGGER.info("Successfully saved {} WKS records in storage", wksRecordTreeList.size());
if (!relationshipStatusList.isEmpty()) {
if(!relationshipStatusList.isEmpty()) {
statusStoreService.createOrUpdateStoreEntry(relationshipStatusList);
LOGGER.info("Successfully saved relationship status for records for which WKS were not found");
}
......@@ -188,8 +168,8 @@ public class WKSServiceImpl implements WKSService {
requestIdentity.setCorrelationId(correlationId);
}
private List<MappingDefinition> retrieveMappings(Map<String, List<MappingDefinition>> mappingsMap,
RawRecordDetails rawRecord) throws ApplicationException {
private List<MappingDefinition> retrieveMappings(Map<String, List<MappingDefinition>> mappingsMap, RawRecordDetails rawRecord)
throws ApplicationException {
List<MappingDefinition> mappings = mappingsMap.get(rawRecord.getKind());
if (isEmptyMappings(mappings)) {
LOGGER.warn(Constants.NO_MAPPING_FOR_KIND, rawRecord.getKind());
......@@ -207,12 +187,13 @@ public class WKSServiceImpl implements WKSService {
private void saveAllWksRecords(List<Tree> wksRecordTreeList, String dataPartitionId, String correlationId)
throws ApplicationException {
String message = this.storageService.putRecords(convertTreeListToJsonStrArr(wksRecordTreeList), dataPartitionId,
correlationId);
String message = this.storageService.putRecords(convertTreeListToJsonStrArr(wksRecordTreeList),
dataPartitionId, correlationId);
LOGGER.info(message);
}
private Tree retrieveRawRecordTree(RawRecordDetails rawRecord) throws ApplicationException, BadRequestException {
private Tree retrieveRawRecordTree(RawRecordDetails rawRecord)
throws ApplicationException, BadRequestException {
Optional<String> optionalRawRecord = storageService.getRecord(rawRecord.getId());
if (!optionalRawRecord.isPresent()) {
......@@ -233,12 +214,11 @@ public class WKSServiceImpl implements WKSService {
return mappings == null || mappings.isEmpty();
}
private Map<String, List<MappingDefinition>> retrieveMappingsMap(RawRecordDetails[] rawRecordsDetails)
throws ApplicationException {
private Map<String, List<MappingDefinition>> retrieveMappingsMap(RawRecordDetails[] rawRecordsDetails) throws ApplicationException {
Map<String, List<MappingDefinition>> mappingsMap = new HashMap<>();
for (RawRecordDetails recordDetails : rawRecordsDetails) {
if (mappingsMap.get(recordDetails.getKind()) == null) {
for(RawRecordDetails recordDetails : rawRecordsDetails) {
if(mappingsMap.get(recordDetails.getKind()) == null) {
List<MappingDefinition> mappings = this.mappingService.getMapping(recordDetails.getKind());
mappingsMap.put(recordDetails.getKind(), mappings);
}
......@@ -296,7 +276,7 @@ public class WKSServiceImpl implements WKSService {
private String[] convertTreeListToJsonStrArr(List<Tree> wksRecordTreeList) {
List<String> wksRecordsJsonStrList = new ArrayList<>();
for (Tree tree : wksRecordTreeList) {
for(Tree tree : wksRecordTreeList) {
wksRecordsJsonStrList.add(tree.toString());
}
return wksRecordsJsonStrList.toArray(new String[0]);
......
......@@ -21,11 +21,9 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.opengroup.osdu.wks.config.RequestIdentity;
import org.opengroup.osdu.wks.config.ThreadJaxRsDpsLog;
import org.opengroup.osdu.wks.constants.Constants;
import org.opengroup.osdu.wks.exceptions.ApplicationException;
import org.opengroup.osdu.wks.exceptions.BadRequestException;
import org.opengroup.osdu.wks.model.RawRecordDetails;
import org.opengroup.osdu.wks.model.TransformRequest;
import org.opengroup.osdu.wks.model.TransformationResult;
......@@ -33,7 +31,6 @@ import org.opengroup.osdu.wks.model.mapping.Mapping;
import org.opengroup.osdu.wks.model.mapping.MappingDefinition;
import org.opengroup.osdu.wks.model.mapping.operation.Operation;
import org.opengroup.osdu.wks.util.WksTransformator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import io.datatree.Tree;
......@@ -47,10 +44,10 @@ public class WKSServiceImplTest {
private static final String ENTITY_TYPE = "entity";
private static final String JSON_SAMPLE_STR = "{\n" + " \"message\": {\n" + " \"data\": [\n" + " {\n"
+ " \"id\": \"datapartition1:source:enitity87e2f18b2eaa40d9876330161fda628e\",\n"
+ " \"kind\": \"datapartition1:source:enitity:1.0.0\",\n"
+ " \"op\": \"create\"\n" + " }\n" + " ],\n"
+ " \"messageId\": \"136969346945\",\n" + " \"publishTime\": \"2019-09-03T14:07:49.215Z\",\n"
+ " \"attributes\": {\n" + " \"account-id\": \"datapartition1\",\n"
+ " \"kind\": \"datapartition1:source:enitity:1.0.0\",\n" + " \"op\": \"create\"\n"
+ " }\n" + " ],\n" + " \"messageId\": \"136969346945\",\n"
+ " \"publishTime\": \"2019-09-03T14:07:49.215Z\",\n" + " \"attributes\": {\n"
+ " \"account-id\": \"datapartition1\",\n"
+ " \"correlation-id\": \"2f40baf1-cef2-4ec8-836e-a4babbda1c4d\",\n"
+ " \"data-partition-id\": \"datapartition1\"\n" + " }\n" + " },\n"
+ " \"subscription\": \"projects/project-id/subscriptions/wks-records-changed-datapartition1\"\n" + "}";
......@@ -60,9 +57,8 @@ public class WKSServiceImplTest {
+ " \"owners\" : [ \"data.default.owners@datapartition1.dev.com\" ]\n" + " },\n"
+ " \"id\" : \"datapartition1:wks:enitity-dGVuYW50MTpwZXRyZWw6d2VsbGJvcmUtZEdWemRGZGxiR3hmWVhWMGIxOWhkSFJsYlhCME5n\",\n"
+ " \"kind\" : \"datapartition1:wks:enitity:1.0.7\",\n" + " \"legal\" : {\n"
+ " \"legaltags\" : [ \"datapartition1-1-abc-test\" ],\n"
+ " \"otherRelevantDataCountries\" : [ \"IN\" ],\n" + " \"status\" : \"compliant\"\n" + " },\n"
+ " \"meta\" : [ {\n" + " \"kind\" : \"CRS\",\n"
+ " \"legaltags\" : [ \"datapartition1-1-abc-test\" ],\n" + " \"otherRelevantDataCountries\" : [ \"IN\" ],\n"
+ " \"status\" : \"compliant\"\n" + " },\n" + " \"meta\" : [ {\n" + " \"kind\" : \"CRS\",\n"
+ " \"persistableReference\" : \"{\\\"wkt\\\":\\\"GEOGCS[\\\\\\\"GCS_WGS_1984\\\\\\\",DATUM[\\\\\\\"D_WGS_1984\\\\\\\",SPHEROID[\\\\\\\"WGS_1984\\\\\\\",6378137.0,298.257223563]],PRIMEM[\\\\\\\"Greenwich\\\\\\\",0.0],UNIT[\\\\\\\"Degree\\\\\\\",0.0174532925199433],AUTHORITY[\\\\\\\"EPSG\\\\\\\",4326]]\\\",\\\"ver\\\":\\\"PE_10_3_1\\\",\\\"name\\\":\\\"GCS_WGS_1984\\\",\\\"authCode\\\":{\\\"auth\\\":\\\"EPSG\\\",\\\"code\\\":\\\"4326\\\"},\\\"type\\\":\\\"LBC\\\"}\",\n"
+ " \"propertyNames\" : [ \"Latitude\", \"Longitude\" ],\n" + " \"name\" : \"GCS_WGS_1984\"\n"
+ " } ],\n" + " \"data\" : {\n" + " \"dateModified\" : \"6/6/2007 14:29\"\n" + " },\n"
......@@ -88,9 +84,6 @@ public class WKSServiceImplTest {
@InjectMocks
private WKSServiceImpl wksService;
@Mock
private ThreadJaxRsDpsLog log;
@Rule