@Override public EndpointGroupStateDto toDto() { EndpointGroupStateDto groupStateDto = new EndpointGroupStateDto(); groupStateDto.setEndpointGroupId(endpointGroupId); groupStateDto.setProfileFilterId(profileFilterId); groupStateDto.setConfigurationId(configurationId); return groupStateDto; } }
@Override public EndpointGroupStateDto toDto() { EndpointGroupStateDto groupStateDto = new EndpointGroupStateDto(); groupStateDto.setEndpointGroupId(endpointGroupId); groupStateDto.setProfileFilterId(profileFilterId); groupStateDto.setConfigurationId(configurationId); return groupStateDto; } }
@Override public HistoryDelta getDelta(EndpointProfileDto profile, String applicationToken, int curAppSeqNumber) { String endpointId = Base64Util.encode(profile); ConfigurationIdKey confIdKey = new ConfigurationIdKey( applicationToken, curAppSeqNumber, profile.getConfigurationVersion()); AppProfileVersionsKey appVersionsKey = new AppProfileVersionsKey( applicationToken, profile.getClientProfileVersion(), profile.getServerProfileVersion()); List<ProfileFilterDto> filters = filterService.getAllMatchingFilters(appVersionsKey, profile); LOG.debug("[{}] Found {} matching filters", endpointId, filters.size()); List<EndpointGroupStateDto> result = new ArrayList<>(1 + filters.size()); EndpointGroupDto groupDto = cacheService.getDefaultGroup(applicationToken); EndpointGroupStateDto groupAllState = new EndpointGroupStateDto(); groupAllState.setEndpointGroupId(groupDto.getId()); groupAllState.setConfigurationId(cacheService.getConfIdByKey( confIdKey.copyWithNewEgId(groupDto.getId()))); result.add(groupAllState); for (ProfileFilterDto filter : filters) { String confId = cacheService.getConfIdByKey( confIdKey.copyWithNewEgId(filter.getEndpointGroupId())); EndpointGroupStateDto endpointGroupState = new EndpointGroupStateDto(); endpointGroupState.setEndpointGroupId(filter.getEndpointGroupId()); endpointGroupState.setProfileFilterId(filter.getId()); endpointGroupState.setConfigurationId(confId); result.add(endpointGroupState); } return new HistoryDelta(result, true, true, true); }
cfGroupStateSave.add(new EndpointGroupStateDto("111", null, null)); cfGroupStateSave.add(new EndpointGroupStateDto("222", null, null)); 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());
EndpointGroupDto endpointGroupDto = new EndpointGroupDto(); endpointGroupDto.setWeight(1); cfGroupStateSave.add(new EndpointGroupStateDto("111", null, null)); cfGroupStateSave.add(new EndpointGroupStateDto("222", null, null)); cfGroupStateSave.add(new EndpointGroupStateDto("333", null, null)); 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());
protected EndpointProfileDto generateEndpointProfileWithGroupIdDto(String endpointGroupId) { EndpointProfileDto profileDto = new EndpointProfileDto(); profileDto.setEndpointKeyHash(generateString("TEST_KEY_HASH").getBytes()); String appId = generateApplicationDto().getId(); profileDto.setApplicationId(appId); List<EndpointGroupStateDto> groupState = new ArrayList<>(); groupState.add(new EndpointGroupStateDto(endpointGroupId, null, null)); profileDto.setGroupState(groupState); try { profileDto.setClientProfileBody(readSchemaFileAsString(TEST_PROFILE_BODY_PATH)); } catch (IOException e) { LOG.error("Can't set client-side EP body {}", e); } profileDto.setServerProfileBody("{\"serverTitle\": \"SERVER_TEST\"}"); profileDto.setSdkToken(UUID.randomUUID().toString()); return endpointService.saveEndpointProfile(profileDto); }
+ "possible configuration/topic list change", endpointId, change.getProfileFilterId()); egs = new EndpointGroupStateDto(groupId, change.getProfileFilterId(), null); groupsMap.put(groupId, egs); historyDelta.setAllChanged();
@Test public void EndpointStateTest() { EndpointGroupStateDto state = new EndpointGroupStateDto(); String groupId = String.valueOf(RANDOM.nextInt(LIMIT)); String filterId = String.valueOf(RANDOM.nextInt(LIMIT)); String configId = String.valueOf(RANDOM.nextInt(LIMIT)); state.setConfigurationId(configId); state.setProfileFilterId(filterId); state.setEndpointGroupId(groupId); CassandraEndpointGroupState stateOne = new CassandraEndpointGroupState(state); CassandraEndpointGroupState stateTwo = new CassandraEndpointGroupState(); stateTwo.setConfigurationId(configId); stateTwo.setProfileFilterId(filterId); stateTwo.setEndpointGroupId(groupId); Assert.assertEquals(stateOne, stateTwo); Assert.assertEquals(stateOne.hashCode(), stateTwo.hashCode()); Assert.assertEquals(stateOne.toDto(), stateTwo.toDto()); Assert.assertEquals(stateOne.toString(), stateTwo.toString()); }
@Test public void EndpointStateTest() { EndpointGroupStateDto state = new EndpointGroupStateDto(); String groupId = String.valueOf(RANDOM.nextInt(LIMIT)); String filterId = String.valueOf(RANDOM.nextInt(LIMIT)); String configId = String.valueOf(RANDOM.nextInt(LIMIT)); state.setConfigurationId(configId); state.setProfileFilterId(filterId); state.setEndpointGroupId(groupId); EndpointGroupState stateOne = new EndpointGroupState(state); EndpointGroupState stateTwo = new EndpointGroupState(); stateTwo.setConfigurationId(configId); stateTwo.setProfileFilterId(filterId); stateTwo.setEndpointGroupId(groupId); Assert.assertEquals(stateOne, stateTwo); Assert.assertEquals(stateOne.hashCode(), stateTwo.hashCode()); Assert.assertEquals(stateOne.toDto(), stateTwo.toDto()); Assert.assertEquals(stateOne.toString(), stateTwo.toString()); }
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(); }