Skip to content
Snippets Groups Projects
Commit 69b124b6 authored by Larissa Pereira's avatar Larissa Pereira
Browse files

test and null check

parent f592af29
No related branches found
No related tags found
1 merge request!587enhance logging to include correlation-id and record-id
Pipeline #200830 failed
...@@ -55,7 +55,11 @@ public class BooleanFeatureFlagClient { ...@@ -55,7 +55,11 @@ public class BooleanFeatureFlagClient {
PartitionInfo partitionInfo = partitionProvider.get(dataPartitionId); PartitionInfo partitionInfo = partitionProvider.get(dataPartitionId);
return partitionInfo; return partitionInfo;
} catch (PartitionException e) { } catch (PartitionException e) {
logger.error(String.format("Error getting partition info for data-partition: %s. Message: %s. ResponseCode: %s.", dataPartitionId, e.getResponse().getBody(), e.getResponse().getResponseCode()), e); if (e.getResponse() != null) {
logger.error(String.format("Error getting partition info for data-partition: %s. Message: %s. ResponseCode: %s.", dataPartitionId, e.getResponse().getBody(), e.getResponse().getResponseCode()), e);
} else {
logger.error(String.format("Error getting partition info for data-partition: %s.", dataPartitionId), e);
}
throw e; throw e;
} }
} }
......
...@@ -24,6 +24,7 @@ import org.junit.Test; ...@@ -24,6 +24,7 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito;
import org.opengroup.osdu.core.common.http.HeadersUtil; import org.opengroup.osdu.core.common.http.HeadersUtil;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.http.AppException;
...@@ -90,6 +91,12 @@ public class RecordIndexerApiTest { ...@@ -90,6 +91,12 @@ public class RecordIndexerApiTest {
should_return400_indexerWorkerTest(messageEmpty, String.format("Required header: '%s' not found", DpsHeaders.DATA_PARTITION_ID)); should_return400_indexerWorkerTest(messageEmpty, String.format("Required header: '%s' not found", DpsHeaders.DATA_PARTITION_ID));
} }
@Test
public void should_addCorrelationIdToHeader_IfExists_indexWorkerTest() throws Exception {
this.sut.indexWorker(createRecordChangedMessage(recordMessageValid));
Mockito.verify(this.requestInfo.getHeaders()).put("correlation-id", "b5a281bd-f59d-4db2-9939-b2d85036fc7e");
}
@Test @Test
public void should_return400_given_incorrectJsonFormatMessage_indexWorkerTest() { public void should_return400_given_incorrectJsonFormatMessage_indexWorkerTest() {
should_return400_indexerWorkerTest(messageWithIncorrectJsonFormat, "Unable to parse request payload."); should_return400_indexerWorkerTest(messageWithIncorrectJsonFormat, "Unable to parse request payload.");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment