use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method postConfigTest.
@Test
public void postConfigTest() throws AlertException {
final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
Mockito.when(configActions.doesConfigExist(Mockito.anyString())).thenReturn(false);
Mockito.when(configActions.saveConfig(Mockito.any())).thenReturn(new CommonDistributionConfigEntity());
final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
final ResponseEntity<String> response = handler.postConfig(restModel);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method putConfigWithInvalidIdTest.
@Test
public void putConfigWithInvalidIdTest() {
final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
Mockito.when(configActions.doesConfigExist(Mockito.anyString())).thenReturn(false);
final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
final ResponseEntity<String> response = handler.putConfig(restModel);
assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class ActionsTest method testConstructRestModel.
@Test
public void testConstructRestModel() throws AlertException {
Mockito.when(configActions.getConfiguredProjectsActions().getConfiguredProjectsRepository().findOne(1L)).thenReturn(projectMockUtils.getProjectOneEntity());
Mockito.when(configActions.getConfiguredProjectsActions().getConfiguredProjectsRepository().findOne(2L)).thenReturn(projectMockUtils.getProjectTwoEntity());
Mockito.when(configActions.getConfiguredProjectsActions().getConfiguredProjectsRepository().findOne(3L)).thenReturn(projectMockUtils.getProjectThreeEntity());
Mockito.when(configActions.getConfiguredProjectsActions().getConfiguredProjectsRepository().findOne(4L)).thenReturn(projectMockUtils.getProjectFourEntity());
Mockito.when(configActions.getConfiguredProjectsActions().getDistributionProjectRepository().findByCommonDistributionConfigId(Mockito.anyLong())).thenReturn(projectMockUtils.getProjectRelations());
final CommonDistributionConfigEntity commonEntity = distributionMockUtils.createEntity();
final R actualRestModel = configActions.constructRestModel(commonEntity, getEntityMockUtil().createEntity());
final R expectedRestModel = getRestMockUtil().createRestModel();
expectedRestModel.setConfiguredProjects(null);
expectedRestModel.setNotificationTypes(null);
assertEquals(expectedRestModel, actualRestModel);
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class DistributionConfigActions method cleanUpStaleChannelConfigurations.
private void cleanUpStaleChannelConfigurations() {
final String distributionName = getDistributionName();
if (distributionName != null) {
final List<D> channelDistributionConfigEntities = getRepository().findAll();
channelDistributionConfigEntities.forEach(entity -> {
final CommonDistributionConfigEntity commonEntity = commonDistributionRepository.findByDistributionConfigIdAndDistributionType(entity.getId(), distributionName);
if (commonEntity == null) {
getRepository().delete(entity);
}
});
}
}
use of com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity in project hub-alert by blackducksoftware.
the class CommonDistributionRepositoryWrapperTest method testFindByDistributionConfigIdAndDistributionType.
@Test
public void testFindByDistributionConfigIdAndDistributionType() throws EncryptionException, IOException {
final CommonDistributionRepositoryWrapper wrapper = getExceptionThrowingRepositoryWrapper();
final CommonDistributionConfigEntity entity = wrapper.findByDistributionConfigIdAndDistributionType(1L, "any");
assertExceptionThrown(entity);
}
Aggregations