Skip to content
Snippets Groups Projects
Commit 1f3e54de authored by Alok Joshi's avatar Alok Joshi
Browse files

Use object mapper

parent 71a61d3d
No related branches found
No related tags found
1 merge request!639Use object mapper
package org.opengroup.osdu.legal.controller; package org.opengroup.osdu.legal.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.http.RequestInfo; import org.opengroup.osdu.core.common.model.http.RequestInfo;
import org.opengroup.osdu.core.common.model.legal.StatusChangedTags;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory;
import org.opengroup.osdu.legal.api.LegalTagStatusJobApi; import org.opengroup.osdu.legal.api.LegalTagStatusJobApi;
...@@ -36,6 +36,8 @@ public class LegalTagStatusJobController implements LegalTagStatusJobApi { ...@@ -36,6 +36,8 @@ public class LegalTagStatusJobController implements LegalTagStatusJobApi {
@Inject @Inject
private JaxRsDpsLog log; private JaxRsDpsLog log;
private ObjectMapper objectMapper = new ObjectMapper();
@Override @Override
public ResponseEntity<HttpStatus> checkLegalTagStatusChanges() { public ResponseEntity<HttpStatus> checkLegalTagStatusChanges() {
tenantStorageFactory.flushCache(); tenantStorageFactory.flushCache();
...@@ -51,7 +53,7 @@ public class LegalTagStatusJobController implements LegalTagStatusJobApi { ...@@ -51,7 +53,7 @@ public class LegalTagStatusJobController implements LegalTagStatusJobApi {
boolean success = true; boolean success = true;
try { try {
LegalTagJobResult result = legalTagStatusJob.run(tenantInfo.getProjectId(), convertedHeaders, tenantInfo.getName()); LegalTagJobResult result = legalTagStatusJob.run(tenantInfo.getProjectId(), convertedHeaders, tenantInfo.getName());
auditLogger.legalTagJobRanSuccess(singletonList(result.toString())); auditLogger.legalTagJobRanSuccess(singletonList(this.objectMapper.writeValueAsString(result)));
} catch (Exception e) { } catch (Exception e) {
success = false; success = false;
log.error( "Error running check LegalTag compliance job on tenant " + convertedHeaders.getPartitionIdWithFallbackToAccountId(), e); log.error( "Error running check LegalTag compliance job on tenant " + convertedHeaders.getPartitionIdWithFallbackToAccountId(), e);
......
package org.opengroup.osdu.legal.controller; package org.opengroup.osdu.legal.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
...@@ -32,6 +33,7 @@ import static org.mockito.Mockito.when; ...@@ -32,6 +33,7 @@ import static org.mockito.Mockito.when;
public class LegalTagStatusJobControllerTest { public class LegalTagStatusJobControllerTest {
public static final DpsHeaders dpsHeaders = new DpsHeaders(); public static final DpsHeaders dpsHeaders = new DpsHeaders();
private ObjectMapper objectMapper = new ObjectMapper();
@Mock @Mock
private RequestInfo requestInfo; private RequestInfo requestInfo;
...@@ -74,7 +76,7 @@ public class LegalTagStatusJobControllerTest { ...@@ -74,7 +76,7 @@ public class LegalTagStatusJobControllerTest {
ResponseEntity<HttpStatus> result = sut.checkLegalTagStatusChanges(); ResponseEntity<HttpStatus> result = sut.checkLegalTagStatusChanges();
assertEquals(HttpStatus.NO_CONTENT, result.getStatusCode()); assertEquals(HttpStatus.NO_CONTENT, result.getStatusCode());
verify(auditLogger).legalTagJobRanSuccess(Collections.singletonList(legalTagJobResult.toString())); verify(auditLogger).legalTagJobRanSuccess(Collections.singletonList(objectMapper.writeValueAsString(legalTagJobResult)));
} }
@Test @Test
......
...@@ -62,6 +62,9 @@ spring.application.name=legal-azure ...@@ -62,6 +62,9 @@ spring.application.name=legal-azure
#logging configuration #logging configuration
logging.transaction.enabled=true logging.transaction.enabled=true
logging.slf4jlogger.enabled=true logging.slf4jlogger.enabled=true
log.sampling.enabled=${log_sampling_enabled:false}
log.sampling.info=${log_sampling_info:100}
log.sampling.dependency=${log_sampling_dependency:100}
logging.mdccontext.enabled=true logging.mdccontext.enabled=true
logging.ignore.servlet.paths=/swagger-ui.html logging.ignore.servlet.paths=/swagger-ui.html
......
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