@Override protected GenericModel<ServerProfileSchemaDto> newInstance(Long id) { return new ServerProfileSchema(id); } }
/** * Create new instance of <code>ProfileFilter</code>. * @param dto data transfer object contain body, * endpoint profile schema id, server profile * schema id. Assign these values on corresponding * fields of new instance */ public ProfileFilter(ProfileFilterDto dto) { super(dto); this.body = dto.getBody(); String endpointSchemaId = dto.getEndpointProfileSchemaId(); if (isNotBlank(endpointSchemaId)) { this.endpointProfileSchema = new EndpointProfileSchema(getLongId(endpointSchemaId)); } String serverSchemaId = dto.getServerProfileSchemaId(); if (isNotBlank(serverSchemaId)) { this.serverProfileSchema = new ServerProfileSchema(getLongId(serverSchemaId)); } }
return getDto(serverProfileSchemaDao.save(new ServerProfileSchema(dto))); } else { throw new IncorrectParameterException("Invalid server profile schema object. Application "
@Test public void findByAppIdAndSchemaVersion() { Application app = generateApplication(null); EndpointProfileSchema schema = generateProfSchema(app, 1).get(0); ServerProfileSchemaDto srvSchema = generateServerProfileSchema(app.getStringId(), app.getTenant().getStringId(), 101); generateFilter(schema, new ServerProfileSchema(srvSchema), null, 2, UpdateStatus.ACTIVE); List<ProfileFilter> filters = generateFilterWithoutSchemaGeneration(schema, new ServerProfileSchema(srvSchema), null, 1, UpdateStatus.ACTIVE); filters.addAll(generateFilterWithoutSchemaGeneration(null, new ServerProfileSchema(srvSchema), null, 1, UpdateStatus.ACTIVE)); filters.addAll(generateFilterWithoutSchemaGeneration(schema, null, null, 1, UpdateStatus.ACTIVE)); List<ProfileFilter> found = profileFilterDao.findByAppIdAndSchemaVersionsCombination(app.getStringId(), schema.getVersion(), srvSchema.getVersion()); Assert.assertEquals(filters, found); }
protected List<ProfileFilter> generateFilter(Application app, EndpointProfileSchema schema, ServerProfileSchema srvSchema, EndpointGroup group, int count, UpdateStatus status) { if (schema == null) { schema = generateProfSchema(app, 1).get(0); } if (srvSchema == null) { srvSchema = new ServerProfileSchema(generateServerProfileSchema(app.getStringId(), app.getTenant().getStringId())); } if (group == null) { group = generateEndpointGroup(app, null); } List<ProfileFilter> filters = new ArrayList<>(); for (int i = 0; i < count; i++) { ProfileFilter dto = new ProfileFilter(); dto.setId(null); dto.setStatus(status != null ? status : UpdateStatus.INACTIVE); dto.setEndpointGroup(group); dto.setEndpointProfileSchema(schema); dto.setServerProfileSchema(srvSchema); dto.setSequenceNumber(i); dto.setApplication(app); ProfileFilter saved = profileFilterDao.save(dto); Assert.assertNotNull(saved); filters.add(saved); } return filters; }