@Override protected ProfileFilterDto newStruct() { return new ProfileFilterDto(); }
@Override protected ProfileFilterDto createDto() { return new ProfileFilterDto(); }
@Test(expected = IncorrectParameterException.class) public void validateFilterBlankSchemaIdTest() throws Throwable { ProfileServiceImpl profileServiceImpl = new ProfileServiceImpl(); Method validateMethod = profileServiceImpl.getClass().getDeclaredMethod("validateFilter", ProfileFilterDto.class); validateMethod.setAccessible(true); ProfileFilterDto filterDto = new ProfileFilterDto(); try { validateMethod.invoke(profileServiceImpl, filterDto); } catch (InvocationTargetException e) { throw e.getCause(); } }
@Test(expected = IncorrectParameterException.class) public void validateFilterBlankEndpointGroupIdTest() throws Throwable { ProfileServiceImpl profileServiceImpl = new ProfileServiceImpl(); Method validateMethod = profileServiceImpl.getClass().getDeclaredMethod("validateFilter", ProfileFilterDto.class); validateMethod.setAccessible(true); ProfileFilterDto filterDto = new ProfileFilterDto(); filterDto.setEndpointGroupId(""); try { validateMethod.invoke(profileServiceImpl, filterDto); } catch (InvocationTargetException e) { throw e.getCause(); } }
@Test(expected = IncorrectParameterException.class) public void saveFilterWithIncorrectIdTestFail() { ProfileFilterDto dto = new ProfileFilterDto(); Assert.assertNotNull(dto); //dto.setId(INCORRECT_ID); profileService.saveProfileFilter(dto); }
@Test(expected = IncorrectParameterException.class) public void saveProfileFilterWithIncorrectSchemaIdTest() { ApplicationDto app = generateApplicationDto(null); String appId = app.getId(); ProfileFilterDto filter = new ProfileFilterDto(); filter.setId(null); filter.setApplicationId(appId); filter.setBody("true"); filter.setEndpointProfileSchemaId(null); filter.setServerProfileSchemaId(null); profileService.saveProfileFilter(filter); }
ProfileFilterDto dto = new ProfileFilterDto(); dto.setId(null); dto.setStatus(null);
@Test(expected = IncorrectParameterException.class) public void saveProfileFilterWithIncorrectGroupIdTest() { ApplicationDto app = generateApplicationDto(null); String appId = app.getId(); EndpointProfileSchemaDto schema = generateProfSchemaDto(app.getTenantId(), appId, 1).get(0); ServerProfileSchemaDto serverProfileSchema = generateServerProfileSchema(app.getId(), app.getTenantId()); ProfileFilterDto filter = new ProfileFilterDto(); filter.setId(null); filter.setApplicationId(appId); filter.setEndpointGroupId(null); filter.setBody("true"); filter.setEndpointProfileSchemaId(schema.getId()); filter.setServerProfileSchemaId(serverProfileSchema.getId()); profileService.saveProfileFilter(filter); }
@Test(expected = UpdateStatusConflictException.class) public void updateDefaultProfileFilter() { ApplicationDto app = generateApplicationDto(null); EndpointProfileSchemaDto schema = generateProfSchemaDto(app.getTenantId(), app.getId(), 1).get(0); ServerProfileSchemaDto serverSchema = generateServerProfileSchema(app.getId(), app.getTenantId()); EndpointGroupDto defaultGroup = endpointService.findDefaultGroup(app.getId()); ProfileFilterDto filter = new ProfileFilterDto(); filter.setApplicationId(app.getId()); filter.setBody("true"); filter.setEndpointProfileSchemaId(schema.getId()); filter.setServerProfileSchemaId(serverSchema.getId()); filter.setEndpointGroupId(defaultGroup.getId()); filter = profileService.saveProfileFilter(filter); profileService.activateProfileFilter(filter.getId(), "test"); }