Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mosip-38491 Fixed api test rig failure #1377

Merged
merged 4 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,14 @@ public ResponseWrapper<List<Map<String,?>>> retrieveVidsfromUin(String uin, int
+ e.getMessage() + ExceptionUtils.getStackTrace(e));
throw new ApisResourceAccessException("Unable to retrieve VID : " + e.getMessage());
}

ResponseWrapper<List<Map<String, ?>>> res = new ResponseWrapper<List<Map<String, ?>>>();
res.setId(residentVidGetId);
res.setVersion(newVersion);
res.setResponsetime(DateUtils.getUTCCurrentDateTimeString());
if(response.getErrors()!=null && !response.getErrors().isEmpty()){
res.setResponse(List.of());
return res;
}
List<Map<String, ?>> filteredList = ((List<Map<String, ?>>) response.getResponse()).stream()
.map(map -> {
LinkedHashMap<String, Object> lhm = new LinkedHashMap<String, Object>(map);
Expand All @@ -112,10 +119,6 @@ public ResponseWrapper<List<Map<String,?>>> retrieveVidsfromUin(String uin, int
})
.filter(map1 -> map1.get(TRANSACTIONS_LEFT_COUNT) == null || (int) map1.get(TRANSACTIONS_LEFT_COUNT) > 0)
.collect(Collectors.toList());
ResponseWrapper<List<Map<String, ?>>> res = new ResponseWrapper<List<Map<String, ?>>>();
res.setId(residentVidGetId);
res.setVersion(newVersion);
res.setResponsetime(DateUtils.getUTCCurrentDateTimeString());
res.setResponse(filteredList);
return res;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.mosip.resident.util;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.mosip.kernel.core.exception.ServiceError;
import io.mosip.resident.constant.ResidentErrorCode;
import io.mosip.resident.dto.ResponseWrapper;
import io.mosip.resident.exception.ApisResourceAccessException;
import io.mosip.resident.exception.ResidentServiceCheckedException;
Expand Down Expand Up @@ -141,5 +143,21 @@ public void testRetrieveVidsfromUin_Exception() throws ResidentServiceCheckedExc
perpetualVidUtil.retrieveVidsfromUin(uin, timeZoneOffset, locale);
});
}

@Test
public void testRetrieveVidsfromUin_EmtpyArray() throws ApisResourceAccessException, ResidentServiceCheckedException {
String uin = "123456789012";
int timeZoneOffset = 0;
String locale = "en";

ResponseWrapper<List<Map<String, ?>>> responseWrapper = new ResponseWrapper<>();
responseWrapper.setErrors(List.of(new ServiceError(ResidentErrorCode.NO_RECORDS_FOUND.getErrorCode(),
ResidentErrorCode.NO_RECORDS_FOUND.getErrorMessage())));

when(residentServiceRestClient.getApi(anyString(), eq(ResponseWrapper.class))).thenReturn(responseWrapper);
ResponseWrapper<List<Map<String, ?>>> result = perpetualVidUtil.retrieveVidsfromUin(uin, timeZoneOffset, locale);
assertNotNull(result);
assertEquals(0, result.getResponse().size());
}
}

Loading