Skip to content

Commit

Permalink
- Fix integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
rathnapandi committed Dec 7, 2023
1 parent 5f33a68 commit e261899
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ public void populateApiId(APIAccess apiAccess) throws AppException {

public void createAPIAccess(APIAccess apiAccess, AbstractEntity parentEntity, Type type) throws AppException {
List<APIAccess> existingAPIAccess = getAPIAccess(parentEntity, type);
if (existingAPIAccess != null &&
existingAPIAccess.stream().anyMatch(existingAPIAccessElement -> existingAPIAccessElement.getApiId().equals(apiAccess.getApiId()))) {
if (existingAPIAccess != null && existingAPIAccess.contains(apiAccess)) {
apiAccess.setId(existingAPIAccess.get(0).getId());
return;
}
Expand Down Expand Up @@ -283,16 +282,14 @@ public void removeClientOrganization(List<Organization> removingActualOrgs, Stri
}

public List<APIAccess> getMissingAPIAccesses(List<APIAccess> apiAccess, List<APIAccess> otherApiAccess) {
List<APIAccess> missingAccess = new ArrayList<>();
if (otherApiAccess == null) otherApiAccess = new ArrayList<>();
if (apiAccess == null) apiAccess = new ArrayList<>();
List<APIAccess> missingAccess = new ArrayList<>();
for (APIAccess access : apiAccess) {
for (APIAccess otherAccess : otherApiAccess) {
if (access.getApiId().equals(otherAccess.getApiId())) {
break;
}
missingAccess.add(access);
if (otherApiAccess.contains(access)) {
continue;
}
missingAccess.add(access);
}
return missingAccess;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,28 +188,28 @@ public void getMissingAPIAccessesWithDuplicates(){
public void getMissingAPIAccessesWithUnique(){
List<APIAccess> apiAccesses = new ArrayList<>();
APIAccess apiAccess = new APIAccess();
apiAccess.setApiId("1235");
apiAccess.setApiName("1235");
apiAccesses.add(apiAccess);
List<APIAccess> otherApiAccess = new ArrayList<>();
APIAccess apiAccess2 = new APIAccess();
apiAccess2.setApiId("12345");
apiAccess2.setApiName("12345");
otherApiAccess.add(apiAccess2);
List<APIAccess> missingApiAccesses = apiManagerAPIAccessAdapter.getMissingAPIAccesses(apiAccesses, otherApiAccess);
Assert.assertEquals("1235",missingApiAccesses.get(0).getApiId());
Assert.assertEquals("1235",missingApiAccesses.get(0).getApiName());
}

@Test
public void getMissingAPIAccessesWithUniqueReverse(){
List<APIAccess> apiAccesses = new ArrayList<>();
APIAccess apiAccess = new APIAccess();
apiAccess.setApiId("1235");
apiAccess.setApiName("1235");
apiAccesses.add(apiAccess);
List<APIAccess> otherApiAccess = new ArrayList<>();
APIAccess apiAccess2 = new APIAccess();
apiAccess2.setApiId("12345");
apiAccess2.setApiName("12345");
otherApiAccess.add(apiAccess2);
List<APIAccess> missingApiAccesses = apiManagerAPIAccessAdapter.getMissingAPIAccesses(otherApiAccess, apiAccesses);
Assert.assertEquals("12345",missingApiAccesses.get(0).getApiId());
Assert.assertEquals("12345",missingApiAccesses.get(0).getApiName());
}


Expand Down

0 comments on commit e261899

Please sign in to comment.