@Test public void getSetTest() { MongoEndpointProfile profile = new MongoEndpointProfile(); profile.setAccessToken(null); profile.setGroupState(null); profile.setChangedFlag(null); profile.setConfigurationHash(null); profile.setEcfVersionStates(null); profile.setEndpointKey(null); profile.setEndpointKeyHash(null); profile.setEndpointUserId(null); profile.setEcfVersionStates(null); profile.setId(null); profile.setTopicHash(null); profile.setProfileHash(null); profile.setServerHash(null); profile.setSubscriptions(null); profile.setUserConfigurationHash(null); profile.setSequenceNumber(1); profile.setConfigurationVersion(1); profile.setLogSchemaVersion(1); profile.setNotificationVersion(1); profile.setProfileVersion(1); profile.setSystemNfVersion(1); profile.setUserNfVersion(1); Assert.assertNull(profile.getAccessToken()); Assert.assertNull(profile.getGroupState());
@Override public void run() { try { MongoEndpointProfile ep = new MongoEndpointProfile(endpointProfile); ep.setEndpointUserId("Ololo " + id); endpointProfileDao.save(ep.toDto()); } catch (KaaOptimisticLockingFailureException ex) { LOG.error("Catch optimistic exception."); throw ex; } } }));
@Test public void convertToDtoTest() { EndpointProfileDto endpointProfile = generateEndpointProfileDto(null, null); endpointProfile.setAccessToken("Trololo"); endpointProfileDao.save(endpointProfile); Assert.assertNotNull(endpointProfile); MongoEndpointProfile converted = new MongoEndpointProfile(endpointProfile); Assert.assertEquals(endpointProfile, converted.toDto()); }
@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()); }
@Override public MongoEndpointProfile save(EndpointProfileDto dto) { return save(new MongoEndpointProfile(dto)); }
@Test public void saveEndpointProfileTest() { EndpointProfileDto endpointProfile = generateEndpointProfileDto(null, null); Assert.assertNotNull(endpointProfile); endpointProfile.setId(null); endpointProfile.setVersion(null); MongoEndpointProfile saved = endpointProfileDao.save(new MongoEndpointProfile(endpointProfile)); Assert.assertNotNull(saved); Assert.assertEquals(endpointProfile, saved.toDto()); }
@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; }