@Test public void testFindBodyByKeyHash() throws Exception { EndpointProfileDto expected = generateEndpointProfileWithEndpointGroupId(null); EndpointProfileBodyDto found = endpointProfileDao.findBodyByKeyHash(expected.getEndpointKeyHash()); Assert.assertFalse(found.getClientSideProfile().isEmpty()); Assert.assertFalse(found.getServerSideProfile().isEmpty()); Assert.assertEquals(expected.getClientProfileBody(), found.getClientSideProfile()); Assert.assertEquals(expected.getServerProfileBody(), found.getServerSideProfile()); }
@Override public EndpointProfileBodyDto getEndpointProfileBodyByKeyHash(String endpointProfileKeyHash) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { EndpointProfileBodyDto profileBodyDto = controlService.getEndpointProfileBodyByKeyHash( endpointProfileKeyHash); Utils.checkNotNull(profileBodyDto); checkApplicationId(profileBodyDto.getAppId()); return profileBodyDto; } catch (Exception ex) { throw Utils.handleException(ex); } }
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; }
@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()); }
EndpointProfileBodyDto endpointProfileBodyDto = new EndpointProfileBodyDto( ep.getEndpointKeyHash(), ep.getClientProfileBody(), ep.getServerProfileVersion(), ep.getApplicationId()); endpointProfileBodyDto.setEndpointKeyHash(ep.getEndpointKeyHash()); profilesBody.add(endpointProfileBodyDto);
Utils.encodeHexString(endpointKeyHash), profile, clientSideProfileVersion, serverSideProfile, serverSideProfileVersion, appId); return new EndpointProfileBodyDto( endpointKeyHash, profile, serverSideProfile, clientSideProfileVersion, serverSideProfileVersion, appId);
@Test public void findEndpointProfileBodyByKeyHashTest() { String endpointGroupId = "124"; EndpointProfileDto savedEndpointProfileDto = generateEndpointProfileWithGroupIdDto(endpointGroupId); EndpointProfileBodyDto endpointProfileBodyDto = endpointService.findEndpointProfileBodyByKeyHash(savedEndpointProfileDto.getEndpointKeyHash()); Assert.assertEquals(savedEndpointProfileDto.getClientProfileBody(), endpointProfileBodyDto.getClientSideProfile()); }
@Override public EndpointProfileBodyDto findBodyByKeyHash(byte[] endpointKeyHash) { LOG.debug("Find endpoint profile body by endpoint key hash [{}] ", endpointKeyHash); EndpointProfileBodyDto endpointProfileBodyDto = null; Query query = Query.query(where(EP_ENDPOINT_KEY_HASH).is(endpointKeyHash)); query.fields() .include(DaoConstants.PROFILE) .include(EP_SERVER_PROFILE_PROPERTY) .include(EP_APPLICATION_ID) .include(EP_PROFILE_VERSION) .include(EP_SERVER_PROFILE_VERSION_PROPERTY) .include(EP_USE_RAW_SCHEMA); EndpointProfileDto pf = mongoTemplate.findOne(query, getDocumentClass()).toDto(); if (pf != null) { endpointProfileBodyDto = new EndpointProfileBodyDto( endpointKeyHash, pf.getClientProfileBody(), pf.getServerProfileBody(), pf.getClientProfileVersion(), pf.getServerProfileVersion(), pf.getApplicationId()); } LOG.debug("[{}] Found client-side endpoint profile body {} with client-side endpoint " + "profile version {} and server-side endpoint profile body {} " + "with server-side endpoint profile version {} and application id {}", endpointKeyHash, pf.getClientProfileBody(), pf.getServerProfileBody(), pf.getClientProfileVersion(), pf.getServerProfileVersion(), pf.getApplicationId()); return endpointProfileBodyDto; }
@Test public void findBodyByKeyHashTest() { EndpointProfileDto endpointProfile = generateEndpointProfileDto(null, null); Assert.assertNotNull(endpointProfile); EndpointProfileBodyDto found = endpointProfileDao.findBodyByKeyHash(endpointProfile.getEndpointKeyHash()); Assert.assertNotNull(found); Assert.assertEquals(endpointProfile.getClientProfileBody(), found.getClientSideProfile()); Assert.assertEquals(endpointProfile.getServerProfileBody(), found.getServerSideProfile()); }