@Override public ServerProfileSchemaDto findLatestServerProfileSchema(String applicationId) throws ControlServiceException { return serverProfileService.findLatestServerProfileSchema(applicationId); }
@Override public ServerProfileSchemaDto getServerProfileSchema(String serverProfileSchemaId) throws ControlServiceException { return serverProfileService.findServerProfileSchema(serverProfileSchemaId); }
@Override public List<ServerProfileSchemaDto> getServerProfileSchemasByApplicationId( String applicationId) throws ControlServiceException { return serverProfileService.findServerProfileSchemasByAppId(applicationId); }
@Test public void testRemoveServerProfileSchemaById() { ServerProfileSchemaDto schemaDto = generateServerProfileSchema(null, null); serverProfileService.removeServerProfileSchemaById(schemaDto.getId()); Assert.assertNull(serverProfileService.findServerProfileSchema(schemaDto.getId())); }
@Override public ServerProfileSchemaDto saveServerProfileSchema(ServerProfileSchemaDto serverProfileSchema) throws ControlServiceException { if (isNotBlank(serverProfileSchema.getCtlSchemaId())) { return serverProfileService.saveServerProfileSchema(serverProfileSchema); } else { LOG.error("Server profile schema has no CTL schema ID"); throw new ControlServiceException("Server profile schema has no CTL schema ID"); } }
@Test public void testRemoveServerProfileSchemaByAppId() { ApplicationDto app = generateApplicationDto(); generateServerProfileSchema(null, null); generateServerProfileSchema(null, null); generateServerProfileSchema(null, null); generateServerProfileSchema(null, null); generateServerProfileSchema(app.getId(), app.getTenantId()); generateServerProfileSchema(app.getId(), app.getTenantId()); generateServerProfileSchema(app.getId(), app.getTenantId()); generateServerProfileSchema(app.getId(), app.getTenantId()); serverProfileService.removeServerProfileSchemaByAppId(app.getId()); List<ServerProfileSchemaDto> found = serverProfileService.findServerProfileSchemasByAppId(app.getId()); Assert.assertTrue(found.isEmpty()); }
@Override public ServerProfileSchemaDto getServerProfileSchemaByApplicationIdAndVersion( String applicationId, int version) throws ControlServiceException { return serverProfileService.findServerProfileSchemaByAppIdAndVersion(applicationId, version); }
String serverProfile) throws ControlServiceException { EndpointProfileDto endpointProfileDto = serverProfileService.saveServerProfile( Base64.decodeBase64(endpointKeyHash), version,
private ServerProfileSchemaDto createDefaultServerProfileSchema(String appId, String createdUsername) { ServerProfileSchemaDto serverProfileSchemaDto = new ServerProfileSchemaDto(); serverProfileSchemaDto.setApplicationId(appId); CTLSchemaDto ctlSchema = ctlService.getOrCreateEmptySystemSchema(createdUsername); serverProfileSchemaDto.setCtlSchemaId(ctlSchema.getId()); serverProfileSchemaDto.setName(DEFAULT_SCHEMA_NAME); serverProfileSchemaDto.setCreatedUsername(createdUsername); return serverProfileService.saveServerProfileSchema(serverProfileSchemaDto); }
@Override public ServerProfileSchemaDto compute(AppVersionKey key) { LOG.debug("Fetching result for getServerProfileSchemaByAppAndVersion"); ApplicationDto appDto = applicationService.findAppByApplicationToken( key.getApplicationToken()); ServerProfileSchemaDto value = serverProfileService.findServerProfileSchemaByAppIdAndVersion(appDto.getId(), key.getVersion()); return value; } });
@Test public void testSaveServerProfile() throws IOException { ServerProfileSchemaDto schemaDto = generateServerProfileSchema(null, null); EndpointProfileDto ep = generateEndpointProfileDtoWithSchemaVersion(schemaDto.getApplicationId(), schemaDto.getVersion(), null); EndpointProfileDto updated = serverProfileService.saveServerProfile(ep.getEndpointKeyHash(), schemaDto.getVersion(), readSchemaFileAsString(TEST_PROFILE_BODY_PATH)); Assert.assertArrayEquals(ep.getEndpointKeyHash(), updated.getEndpointKeyHash()); Assert.assertNotEquals(ep.getServerProfileBody(), updated.getServerProfileBody()); Assert.assertEquals(ep.getServerProfileVersion(), updated.getServerProfileVersion()); }
String appId = group.getApplicationId(); List<ServerProfileSchemaDto> serverSchemas = serverProfileService .findServerProfileSchemasByAppId(appId); Collections.sort(serverSchemas); List<EndpointProfileSchemaDto> endpointProfileSchemas = findProfileSchemasByAppId(appId);
serverProfileSchemaDto = serverProfileService.findServerProfileSchema(srvProfSchemaId); if (serverProfileSchemaDto == null) { throw new IncorrectParameterException("Can't update profile filter, "
protected ServerProfileSchemaDto generateServerProfileSchema(String appId, String tenantId, int version) { ServerProfileSchemaDto schemaDto = new ServerProfileSchemaDto(); if (isBlank(tenantId)) { ApplicationDto applicationDto = generateApplicationDto(); appId = applicationDto.getId(); tenantId = applicationDto.getTenantId(); } schemaDto.setApplicationId(appId); schemaDto.setCreatedTime(System.currentTimeMillis()); CTLSchemaDto ctlSchema = ctlService.saveCtlSchema(generateCTLSchemaDto(ctlRandomFqn(), tenantId, appId, version)); schemaDto.setCtlSchemaId(ctlSchema.getId()); return serverProfileService.saveServerProfileSchema(schemaDto); }
== null) { ServerProfileSchemaDto serverProfileSchemaDto = serverProfileService .findLatestServerProfileSchema(endpointProfileDto.getApplicationId()); CTLSchemaDto schemaDto = ctlService.findCtlSchemaById( serverProfileSchemaDto.getCtlSchemaId());
@Test @Ignore("generateEndpointProfileDtoWithSchemaVersion() updates profile," + " but it shouldn't have existed by the moment, so save must have have been invoked") public void testFindServerProfileSchemaByKeyHash() { ServerProfileSchemaDto schemaDto = generateServerProfileSchema(null, null); EndpointProfileDto ep = generateEndpointProfileDtoWithSchemaVersion(schemaDto.getApplicationId(), schemaDto.getVersion(), null); EndpointProfileDto found = endpointService.findEndpointProfileByKeyHash(ep.getEndpointKeyHash()); ServerProfileSchemaDto foundSchema = serverProfileService.findServerProfileSchemaByAppIdAndVersion(found.getApplicationId(), found.getServerProfileVersion()); Assert.assertEquals(schemaDto, foundSchema); }
@Test public void testFindServerProfileSchemasByAppId() { ApplicationDto app = generateApplicationDto(); List<ServerProfileSchemaDto> found = serverProfileService.findServerProfileSchemasByAppId(app.getId()); Assert.assertEquals(1, found.size()); generateServerProfileSchema(null, null); generateServerProfileSchema(null, null); generateServerProfileSchema(null, null); generateServerProfileSchema(null, null); List<ServerProfileSchemaDto> expected = new ArrayList<>(); expected.add(found.get(0)); expected.add(generateServerProfileSchema(app.getId(), app.getTenantId())); expected.add(generateServerProfileSchema(app.getId(), app.getTenantId())); expected.add(generateServerProfileSchema(app.getId(), app.getTenantId())); expected.add(generateServerProfileSchema(app.getId(), app.getTenantId())); found = serverProfileService.findServerProfileSchemasByAppId(app.getId()); Assert.assertEquals(expected, found); }
serverProfileSchemaDto = generateServerProfileSchema(app.getId(), app.getTenantId()); } else { serverProfileSchemaDto = serverProfileService.findServerProfileSchema(serverSchemaId);
@Test public void testFindLatestServerProfileSchema() { ApplicationDto app = generateApplicationDto(); generateServerProfileSchema(app.getId(), app.getTenantId()); generateServerProfileSchema(app.getId(), app.getTenantId()); generateServerProfileSchema(app.getId(), app.getTenantId()); generateServerProfileSchema(app.getId(), app.getTenantId()); ServerProfileSchemaDto expected = generateServerProfileSchema(app.getId(), app.getTenantId()); ServerProfileSchemaDto last = serverProfileService.findLatestServerProfileSchema(app.getId()); Assert.assertEquals(expected, last); }
: serverProfileService.findServerProfileSchemasByAppId(appDto.getId())) { LOG.debug("Processing version {}", version); cacheService.resetFilters(new AppProfileVersionsKey(