From 0824f8899281e10631c32bf164fc34868e4b910b Mon Sep 17 00:00:00 2001 From: Nathan Dickerson Date: Wed, 21 Oct 2020 15:15:31 -0500 Subject: [PATCH] fix(Meta): Fix meta call to work with latest Rest SDK (#329) --- dataloader.iml | 2 +- .../java/com/bullhorn/dataloader/service/MetaService.java | 4 +++- .../com/bullhorn/dataloader/service/MetaServiceTest.java | 8 ++++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dataloader.iml b/dataloader.iml index acb4a763..5adf15b8 100644 --- a/dataloader.iml +++ b/dataloader.iml @@ -152,7 +152,7 @@ - + diff --git a/src/main/java/com/bullhorn/dataloader/service/MetaService.java b/src/main/java/com/bullhorn/dataloader/service/MetaService.java index 43700415..80ade096 100644 --- a/src/main/java/com/bullhorn/dataloader/service/MetaService.java +++ b/src/main/java/com/bullhorn/dataloader/service/MetaService.java @@ -11,6 +11,8 @@ import com.bullhornsdk.data.model.entity.meta.Field; import com.bullhornsdk.data.model.entity.meta.MetaData; import com.bullhornsdk.data.model.enums.MetaParameter; +import com.google.common.collect.Sets; + import org.json.JSONArray; import org.json.JSONObject; @@ -41,7 +43,7 @@ public void run(String[] args) { try { printUtil.log("Getting meta for " + Objects.requireNonNull(entityInfo).getEntityName() + "..."); - MetaData metaData = restApi.getMetaData(entityInfo.getEntityClass(), MetaParameter.FULL, null); + MetaData metaData = restApi.getMetaData(entityInfo.getEntityClass(), MetaParameter.FULL, Sets.newHashSet(StringConsts.ALL_FIELDS)); enrichMeta(metaData); JSONObject jsonMeta = metaToJson(metaData); printUtil.print(jsonMeta.toString()); diff --git a/src/test/java/com/bullhorn/dataloader/service/MetaServiceTest.java b/src/test/java/com/bullhorn/dataloader/service/MetaServiceTest.java index da0b6fe6..72783a81 100644 --- a/src/test/java/com/bullhorn/dataloader/service/MetaServiceTest.java +++ b/src/test/java/com/bullhorn/dataloader/service/MetaServiceTest.java @@ -6,12 +6,14 @@ import com.bullhorn.dataloader.rest.RestApi; import com.bullhorn.dataloader.rest.RestSession; import com.bullhorn.dataloader.util.PrintUtil; +import com.bullhorn.dataloader.util.StringConsts; import com.bullhornsdk.data.exception.RestApiException; import com.bullhornsdk.data.model.entity.core.standard.Candidate; import com.bullhornsdk.data.model.entity.core.standard.CorporateUser; import com.bullhornsdk.data.model.entity.meta.Field; import com.bullhornsdk.data.model.entity.meta.StandardMetaData; import com.bullhornsdk.data.model.enums.MetaParameter; +import com.google.common.collect.Sets; import org.json.JSONArray; import org.json.JSONObject; import org.junit.Assert; @@ -23,6 +25,7 @@ import java.util.Arrays; import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; @@ -71,7 +74,8 @@ public void setup() { candidateMeta.setFields(new ArrayList<>(Arrays.asList(idField, emailField, commentsField, customTextField, customIntField, ownerField, addressField))); when(restSessionMock.getRestApi()).thenReturn(restApiMock); - when(restApiMock.getMetaData(Candidate.class, MetaParameter.FULL, null)).thenReturn(candidateMeta); + when(restApiMock.getMetaData(eq(Candidate.class), eq(MetaParameter.FULL), eq(Sets.newHashSet(StringConsts.ALL_FIELDS)))) + .thenReturn(candidateMeta); } @Test @@ -128,7 +132,7 @@ public void testRunBadConnection() { @Test public void testRunMetaCallException() { - when(restApiMock.getMetaData(Candidate.class, MetaParameter.FULL, null)) + when(restApiMock.getMetaData(eq(Candidate.class), eq(MetaParameter.FULL), eq(Sets.newHashSet(StringConsts.ALL_FIELDS)))) .thenThrow(new RestApiException("Meta Error")); metaService.run(new String[]{Command.META.getMethodName(), "Candidate"});