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

Merge branch 'fix_json_mapping' into 'master'

Use object mapper

See merge request !639
parents 8a32cb81 1f3e54de
Branches trusted-EPMOSDU-1401-sast-fix
No related tags found
1 merge request!639Use object mapper
Pipeline #302212 failed
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.model.http.DpsHeaders;
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.provider.interfaces.ITenantFactory;
import org.opengroup.osdu.legal.api.LegalTagStatusJobApi;
......@@ -36,6 +36,8 @@ public class LegalTagStatusJobController implements LegalTagStatusJobApi {
@Inject
private JaxRsDpsLog log;
private ObjectMapper objectMapper = new ObjectMapper();
@Override
public ResponseEntity<HttpStatus> checkLegalTagStatusChanges() {
tenantStorageFactory.flushCache();
......@@ -51,7 +53,7 @@ public class LegalTagStatusJobController implements LegalTagStatusJobApi {
boolean success = true;
try {
LegalTagJobResult result = legalTagStatusJob.run(tenantInfo.getProjectId(), convertedHeaders, tenantInfo.getName());
auditLogger.legalTagJobRanSuccess(singletonList(result.toString()));
auditLogger.legalTagJobRanSuccess(singletonList(this.objectMapper.writeValueAsString(result)));
} catch (Exception e) {
success = false;
log.error( "Error running check LegalTag compliance job on tenant " + convertedHeaders.getPartitionIdWithFallbackToAccountId(), e);
......
package org.opengroup.osdu.legal.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -32,6 +33,7 @@ import static org.mockito.Mockito.when;
public class LegalTagStatusJobControllerTest {
public static final DpsHeaders dpsHeaders = new DpsHeaders();
private ObjectMapper objectMapper = new ObjectMapper();
@Mock
private RequestInfo requestInfo;
......@@ -74,7 +76,7 @@ public class LegalTagStatusJobControllerTest {
ResponseEntity<HttpStatus> result = sut.checkLegalTagStatusChanges();
assertEquals(HttpStatus.NO_CONTENT, result.getStatusCode());
verify(auditLogger).legalTagJobRanSuccess(Collections.singletonList(legalTagJobResult.toString()));
verify(auditLogger).legalTagJobRanSuccess(Collections.singletonList(objectMapper.writeValueAsString(legalTagJobResult)));
}
@Test
......
......@@ -62,6 +62,9 @@ spring.application.name=legal-azure
#logging configuration
logging.transaction.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.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