private PageLinkDto getPageLinkDto() { List<EndpointProfileDto> endpointProfileList = new ArrayList<>(); for (int i = 0; i < GENERATED_PROFILES_COUNT; i++) { endpointProfileList.add(generateEndpointProfileWithEndpointGroupId(TEST_APPID)); } String id = endpointProfileList.get(0).getGroupState().get(0).getEndpointGroupId(); return new PageLinkDto(id, TEST_LIMIT, TEST_OFFSET); }
private EndpointProfilesBodyDto createNextBodyPage(List<EndpointProfileBodyDto> profilesBodyDto, String endpointGroupId, String limit) { EndpointProfilesBodyDto endpointProfilesBodyDto = new EndpointProfilesBodyDto(); PageLinkDto pageLinkDto = new PageLinkDto(); String next; int lim = Integer.valueOf(limit); if (profilesBodyDto.size() == (lim + 1)) { pageLinkDto.setEndpointGroupId(endpointGroupId); pageLinkDto.setLimit(limit); pageLinkDto.setOffset( Base64.encodeBase64URLSafeString(profilesBodyDto.get(lim).getEndpointKeyHash())); profilesBodyDto.remove(lim); next = null; } else { next = DaoConstants.LAST_PAGE_MESSAGE; } pageLinkDto.setNext(next); endpointProfilesBodyDto.setPageLinkDto(pageLinkDto); endpointProfilesBodyDto.setEndpointProfilesBody(profilesBodyDto); return endpointProfilesBodyDto; }
private EndpointProfilesPageDto createNextPage( List<EndpointProfileDto> cassandraEndpointProfileList, String endpointGroupId, String limit ) { EndpointProfilesPageDto endpointProfilesPageDto = new EndpointProfilesPageDto(); PageLinkDto pageLinkDto = new PageLinkDto(); String next; int lim = Integer.valueOf(limit); if (cassandraEndpointProfileList.size() == (lim + 1)) { pageLinkDto.setEndpointGroupId(endpointGroupId); pageLinkDto.setLimit(limit); pageLinkDto.setOffset(Base64.encodeBase64URLSafeString( cassandraEndpointProfileList.get(lim).getEndpointKeyHash())); cassandraEndpointProfileList.remove(lim); next = null; } else { next = DaoConstants.LAST_PAGE_MESSAGE; } pageLinkDto.setNext(next); endpointProfilesPageDto.setPageLinkDto(pageLinkDto); endpointProfilesPageDto.setEndpointProfiles(cassandraEndpointProfileList); return endpointProfilesPageDto; }
@Override public EndpointProfilesPageDto getEndpointProfileByEndpointGroupId(String endpointGroupId, String limit, String offset) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { if (Integer.valueOf(limit) > MAX_LIMIT) { throw new IllegalArgumentException( "Incorrect limit parameter. You must enter value not more than " + MAX_LIMIT); } EndpointGroupDto endpointGroupDto = getEndpointGroup(endpointGroupId); PageLinkDto pageLinkDto = new PageLinkDto(endpointGroupId, limit, offset); if (isGroupAll(endpointGroupDto)) { pageLinkDto.setApplicationId(endpointGroupDto.getApplicationId()); } return controlService.getEndpointProfileByEndpointGroupId(pageLinkDto); } catch (Exception ex) { throw Utils.handleException(ex); } }
@Override public EndpointProfilesBodyDto getEndpointProfileBodyByEndpointGroupId(String endpointGroupId, String limit, String offset) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { if (Integer.valueOf(limit) > MAX_LIMIT) { throw new IllegalArgumentException( "Incorrect limit parameter. You must enter value not more than " + MAX_LIMIT); } EndpointGroupDto endpointGroupDto = getEndpointGroup(endpointGroupId); PageLinkDto pageLinkDto = new PageLinkDto(endpointGroupId, limit, offset); if (isGroupAll(endpointGroupDto)) { pageLinkDto.setApplicationId(endpointGroupDto.getApplicationId()); } return controlService.getEndpointProfileBodyByEndpointGroupId(pageLinkDto); } catch (Exception ex) { throw Utils.handleException(ex); } }
@Test public void findBodyByEndpointGroupIdTest() { for (int i = 0; i < GENERATED_PROFILES_COUNT; i++) { generateEndpointProfileWithGroupIdDto(TEST_ENDPOINT_GROUP_ID); } int lim = Integer.valueOf(TEST_LIMIT); PageLinkDto pageLink = new PageLinkDto(TEST_ENDPOINT_GROUP_ID, TEST_LIMIT, TEST_OFFSET); EndpointProfilesBodyDto found = endpointProfileDao.findBodyByEndpointGroupId(pageLink); Assert.assertFalse(found.getEndpointProfilesBody().isEmpty()); Assert.assertEquals(lim, found.getEndpointProfilesBody().size()); }
@Test public void findByEndpointGroupIdTest() { for (int i = 0; i < GENERATED_PROFILES_COUNT; i++) { generateEndpointProfileWithGroupIdDto(TEST_ENDPOINT_GROUP_ID); } int lim = Integer.valueOf(TEST_LIMIT); PageLinkDto pageLink = new PageLinkDto(TEST_ENDPOINT_GROUP_ID, TEST_LIMIT, TEST_OFFSET); EndpointProfilesPageDto found = endpointProfileDao.findByEndpointGroupId(pageLink); Assert.assertFalse(found.getEndpointProfiles().isEmpty()); Assert.assertEquals(lim, found.getEndpointProfiles().size()); }
@Test public void findBodyByEndpointGroupIdWithNfGroupStateTest() { for (int i = 0; i < GENERATED_PROFILES_COUNT; i++) { generateEndpointProfileWithGroupIdDto(TEST_ENDPOINT_GROUP_ID); } int lim = Integer.valueOf(TEST_LIMIT); PageLinkDto pageLink = new PageLinkDto(TEST_ENDPOINT_GROUP_ID, TEST_LIMIT, TEST_OFFSET); EndpointProfilesBodyDto found = endpointProfileDao.findBodyByEndpointGroupId(pageLink); Assert.assertFalse(found.getEndpointProfilesBody().isEmpty()); Assert.assertEquals(lim, found.getEndpointProfilesBody().size()); }
@Test public void findByEndpointGroupIdWithNfGroupStateTest() { for (int i = 0; i < GENERATED_PROFILES_COUNT; i++) { generateEndpointProfileWithGroupIdDto(TEST_ENDPOINT_GROUP_ID); } int lim = Integer.valueOf(TEST_LIMIT); PageLinkDto pageLink = new PageLinkDto(TEST_ENDPOINT_GROUP_ID, TEST_LIMIT, TEST_OFFSET); EndpointProfilesPageDto found = endpointProfileDao.findByEndpointGroupId(pageLink); Assert.assertFalse(found.getEndpointProfiles().isEmpty()); Assert.assertEquals(lim, found.getEndpointProfiles().size()); }
@Test public void findEndpointProfileByEndpointGroupIdTest() { EndpointGroupDto group = generateEndpointGroupDto(null); String endpointGroupId = group.getId(); PageLinkDto pageLinkDto = new PageLinkDto(endpointGroupId, DEFAULT_LIMIT, DEFAULT_OFFSET); EndpointProfileDto savedEndpointProfileDto = generateEndpointProfileWithGroupIdDto(endpointGroupId); EndpointProfilesPageDto endpointProfilesPage = endpointService.findEndpointProfileByEndpointGroupId(pageLinkDto); EndpointProfileDto endpointProfileDto = endpointProfilesPage.getEndpointProfiles().get(0); Assert.assertEquals(savedEndpointProfileDto, endpointProfileDto); }
String[] endpointGroupId = {"111", "444", "222", "333"}; for (int i = 0; i < 2; i++) { pageLink = new PageLinkDto(endpointGroupId[i], limit, offset); found = endpointProfileDao.findByEndpointGroupId(pageLink); Assert.assertFalse(found.getEndpointProfiles().isEmpty()); pageLink = new PageLinkDto(endpointGroupId[i], limit, offset); found = endpointProfileDao.findByEndpointGroupId(pageLink); Assert.assertTrue(found.getEndpointProfiles().isEmpty());
@Test public void findEndpointProfileBodyByEndpointGroupIdTest() { EndpointGroupDto group = generateEndpointGroupDto(null); String endpointGroupId = group.getId(); PageLinkDto pageLinkDto = new PageLinkDto(endpointGroupId, DEFAULT_LIMIT, DEFAULT_OFFSET); EndpointProfileDto savedEndpointProfileDto = generateEndpointProfileWithGroupIdDto(endpointGroupId); EndpointProfilesBodyDto endpointProfilesPage = endpointService.findEndpointProfileBodyByEndpointGroupId(pageLinkDto); EndpointProfileBodyDto endpointProfileBodyDto = endpointProfilesPage.getEndpointProfilesBody().get(0); Assert.assertEquals(savedEndpointProfileDto.getClientProfileBody(), endpointProfileBodyDto.getClientSideProfile()); }
String[] endpointGroupId = {"111", "444", "222", "333"}; for (int i = 0; i < 2; i++) { pageLink = new PageLinkDto(endpointGroupId[i], limit, offset); found = endpointProfileDao.findByEndpointGroupId(pageLink); Assert.assertFalse(found.getEndpointProfiles().isEmpty()); pageLink = new PageLinkDto(endpointGroupId[i], limit, offset); found = endpointProfileDao.findByEndpointGroupId(pageLink); Assert.assertTrue(found.getEndpointProfiles().isEmpty());