@Override public EndpointProfileDto findEndpointProfileByKeyHash(byte[] endpointProfileKeyHash) { validateHash(endpointProfileKeyHash, "Can't find endpoint profile by key hash. Invalid key " + "hash " + endpointProfileKeyHash); return getDto(endpointProfileDao.findByKeyHash(endpointProfileKeyHash)); }
LOG.warn("Optimistic lock detected in endpoint profile ", Arrays.toString(endpoint .getEndpointKey()), ex); endpoint = getDto(endpointProfileDao.findByKeyHash(Sha1HashUtils.hashToBytes(endpoint .getEndpointKey())));
LOG.warn("Optimistic lock detected in endpoint profile ", Arrays.toString(endpoint .getEndpointKey()), ex); endpoint = endpointProfileDao.findByKeyHash(Sha1HashUtils.hashToBytes(endpoint .getEndpointKey()));
@Override public void removeEndpointProfileByKeyHash(byte[] endpointProfileKeyHash) { validateHash(endpointProfileKeyHash, "Can't remove endpoint profile by key hash. Invalid key " + "hash " + endpointProfileKeyHash); EndpointProfile endpointProfile = endpointProfileDao.findByKeyHash(endpointProfileKeyHash); if (endpointProfile != null) { if (isValidId(endpointProfile.getEndpointUserId())) { detachEndpointFromUser(getDto(endpointProfile)); } endpointProfileDao.removeByKeyHash(endpointProfileKeyHash); } else { throw new DatabaseProcessingException("Endpoint profile is not present in db."); } }
@Test public void testRemoveByIdNullKey() throws Exception { EndpointProfileDto expected = generateEndpointProfile(null, null, null, null); EndpointProfile found = endpointProfileDao.findByKeyHash(expected.getEndpointKeyHash()); Assert.assertNotNull(found); }
@Test public void testRemoveById() throws Exception { EndpointProfileDto expected = generateEndpointProfile(null, null, null, null); endpointProfileDao.removeById(ByteBuffer.wrap(expected.getEndpointKeyHash())); EndpointProfile found = endpointProfileDao.findByKeyHash(expected.getEndpointKeyHash()); Assert.assertNull(found); }
@Test public void testSave() throws Exception { EndpointProfileDto endpointProfile = generateEndpointProfile(null, null, null, null); EndpointProfile found = endpointProfileDao.findByKeyHash(endpointProfile.getEndpointKeyHash()); Assert.assertEquals(endpointProfile, found.toDto()); }
@Test public void testFindByKeyHash() throws Exception { EndpointProfileDto expected = generateEndpointProfile(null, null, null, null); EndpointProfile found = endpointProfileDao.findByKeyHash(expected.getEndpointKeyHash()); Assert.assertEquals(expected, found.toDto()); }
@Test public void testRemoveByKeyHash() throws Exception { EndpointProfileDto expected = generateEndpointProfile(null, null, null, null); endpointProfileDao.removeByKeyHash(expected.getEndpointKeyHash()); EndpointProfile found = endpointProfileDao.findByKeyHash(expected.getEndpointKeyHash()); Assert.assertNull(found); }
EndpointProfile storedProfile = endpointProfileDao.findByKeyHash(keyHash); if (storedProfile == null) {
byte[] endpointKeyHash = dto.getEndpointKeyHash(); if (endpointKeyHash != null) { EndpointProfile ep = endpointProfileDao.findByKeyHash(endpointKeyHash); if (ep == null) { throw new DatabaseProcessingException("Can't find endpoint profile by hash "
@Test public void removeByAppId() { EndpointProfileDto endpointProfile = generateEndpointProfileDto(null, null); Assert.assertNotNull(endpointProfile); byte[] keyHash = endpointProfile.getEndpointKeyHash(); endpointProfileDao.removeByAppId(endpointProfile.getApplicationId()); MongoEndpointProfile found = endpointProfileDao.findByKeyHash(keyHash); Assert.assertNull(found); }
@Test public void testFindByKeyHash() { EndpointProfileDto endpointProfile = generateEndpointProfileDto(null, null); Assert.assertNotNull(endpointProfile); MongoEndpointProfile found = endpointProfileDao.findByKeyHash(endpointProfile.getEndpointKeyHash()); Assert.assertNotNull(found); Assert.assertEquals(endpointProfile, found.toDto()); }
@Test public void testRemoveByKeyHash() { EndpointProfileDto endpointProfile = generateEndpointProfileDto(null, null); Assert.assertNotNull(endpointProfile); endpointProfileDao.removeByKeyHash(endpointProfile.getEndpointKeyHash()); MongoEndpointProfile profile = endpointProfileDao.findByKeyHash(endpointProfile.getEndpointKeyHash()); Assert.assertNull(profile); }