use of com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method postConfigWithConflictTest.
@Test
public void postConfigWithConflictTest() {
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(true);
final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
final ResponseEntity<String> response = handler.postConfig(restModel);
assertEquals(HttpStatus.CONFLICT, response.getStatusCode());
}
use of com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method getConfigTest.
@Test
public void getConfigTest() throws AlertException {
final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
final List<CommonDistributionConfigRestModel> restModel = Arrays.asList(mockCommonDistributionRestModel.createEmptyRestModel());
Mockito.when(configActions.getConfig(Mockito.anyLong())).thenReturn(restModel);
final List<CommonDistributionConfigRestModel> list = handler.getConfig(null);
assertEquals(restModel, list);
}
use of com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions 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.web.actions.distribution.CommonDistributionConfigActions 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.web.actions.distribution.CommonDistributionConfigActions in project hub-alert by blackducksoftware.
the class CommonConfigHandlerTest method postWithInvalidConfigTest.
@Test
public void postWithInvalidConfigTest() throws AlertFieldException {
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.validateConfig(Mockito.any())).thenThrow(new AlertFieldException(Collections.emptyMap()));
Mockito.when(configActions.getObjectTransformer()).thenReturn(objectTransformer);
final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
final ResponseEntity<String> response = handler.postConfig(restModel);
assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
}
Aggregations