@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; } } }));
@Override public void run() { try { CassandraEndpointProfile ep = new CassandraEndpointProfile(endpointProfile); ep.setEndpointUserId("Ololo " + id); endpointProfileDao.save(ep.toDto()); } catch (KaaOptimisticLockingFailureException ex) { LOG.error("Catch optimistic exception."); throw ex; } } }));
endpoint.setEndpointUserId(endpointUser.getId()); LOG.trace("Save endpoint user {} and endpoint profile {}", endpointUser, endpoint); endpoint = endpointProfileDao.save(endpoint); break; } catch (KaaOptimisticLockingFailureException ex) {
if (storedProfile == null) { dto = getDto(endpointProfileDao.save(endpointProfileDto)); } else { if (Arrays.equals(storedProfile.getEndpointKey(), endpointProfileDto.getEndpointKey())) { endpointProfileDto.setId(storedProfile.getId()); endpointProfileDto.setVersion(storedProfile.getVersion()); dto = getDto(endpointProfileDao.save(endpointProfileDto)); } else { LOG.warn("Endpoint profile with key hash {} already exists.", keyHash); dto = getDto(endpointProfileDao.save(endpointProfileDto));
cfGroupStateSave.add(new EndpointGroupStateDto("333", null, null)); EndpointProfileDto endpointProfileSave = generateEndpointProfileForTestUpdate(null, "TEST_KEY_HASH".getBytes(), cfGroupStateSave); EndpointProfile saved = endpointProfileDao.save(endpointProfileSave); cfGroupStateUpdate.add(new EndpointGroupStateDto("111", null, null)); cfGroupStateUpdate.add(new EndpointGroupStateDto("444", null, null)); EndpointProfileDto endpointProfileUpdate = generateEndpointProfileForTestUpdate(saved.getId(), "TEST_KEY_HASH".getBytes(), cfGroupStateUpdate); endpointProfileUpdate.setVersion(saved.getVersion()); endpointProfileDao.save(endpointProfileUpdate); String limit = "10"; String offset = "0";
byte[] keyHash = generateBytes(); EndpointProfileDto endpointProfileSave = generateEndpointProfileForTestUpdate(null, keyHash, cfGroupStateSave); EndpointProfile saved = endpointProfileDao.save(endpointProfileSave); cfGroupStateUpdate.add(new EndpointGroupStateDto("111", null, null)); cfGroupStateUpdate.add(new EndpointGroupStateDto("444", null, null)); EndpointProfileDto endpointProfileUpdate = generateEndpointProfileForTestUpdate(endpointProfileId, keyHash, cfGroupStateUpdate); endpointProfileUpdate.setVersion(saved.getVersion()); saved = endpointProfileDao.save(endpointProfileUpdate); String limit = "10"; String offset = "0";
protected EndpointProfileDto generateEndpointProfileWithEndpointGroupId(String appId) { byte[] keyHash = generateBytes(); if (appId == null) { appId = generateStringId(); } EndpointProfileDto profileDto = new EndpointProfileDto(); profileDto.setApplicationId(appId); profileDto.setEndpointKeyHash(keyHash); profileDto.setAccessToken(generateStringId()); profileDto.setClientProfileBody("test profile"); profileDto.setServerProfileBody("test server-side profile"); profileDto.setEpsConfigurationHash(EPS_CONFIG_HASH); List<EndpointGroupStateDto> groupState = new ArrayList<>(); groupState.add(new EndpointGroupStateDto(TEST_ENDPOINT_GROUP_ID, null, null)); profileDto.setGroupState(groupState); profileDto.setSdkToken(UUID.randomUUID().toString()); return endpointProfileDao.save(new CassandraEndpointProfile(profileDto)).toDto(); }
@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 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()); }
protected EndpointProfileDto generateEndpointProfile(String appId, String sdkToken, String accessToken, List<String> topicIds, CtlDataDto ctlDataDto) { byte[] keyHash = generateBytes(); if (appId == null) { appId = generateStringId(); } if (sdkToken == null) { sdkToken = generateStringId(); } if (accessToken == null) { accessToken = generateStringId(); } EndpointProfileDto profileDto = new EndpointProfileDto(); profileDto.setApplicationId(appId); profileDto.setSdkToken(sdkToken); profileDto.setSubscriptions(topicIds); profileDto.setEndpointKeyHash(keyHash); profileDto.setAccessToken(accessToken); profileDto.setEpsConfigurationHash(EPS_CONFIG_HASH); if (ctlDataDto != null) { profileDto.setServerProfileBody(ctlDataDto.getBody()); profileDto.setServerProfileVersion(ctlDataDto.getServerProfileVersion()); } return endpointProfileDao.save(new CassandraEndpointProfile(profileDto)).toDto(); }