Search in sources :

Example 6 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper in project hub-alert by blackducksoftware.

the class CommonConfigHandlerTest method getConfigHandleExceptionTest.

@Test
public void getConfigHandleExceptionTest() 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.getConfig(Mockito.anyLong())).thenThrow(new AlertException());
    Exception thrownException = null;
    List<CommonDistributionConfigRestModel> list = null;
    try {
        list = handler.getConfig(1L);
    } catch (final Exception e) {
        thrownException = e;
    }
    assertNull(thrownException);
    assertEquals(Collections.emptyList(), list);
}
Also used : CommonDistributionConfigActions(com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) AlertException(com.blackducksoftware.integration.hub.alert.exception.AlertException) AlertFieldException(com.blackducksoftware.integration.hub.alert.exception.AlertFieldException) IntegrationRestException(com.blackducksoftware.integration.hub.rest.exception.IntegrationRestException) AlertException(com.blackducksoftware.integration.hub.alert.exception.AlertException) IntegrationException(com.blackducksoftware.integration.exception.IntegrationException) Test(org.junit.Test)

Example 7 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper in project hub-alert by blackducksoftware.

the class CommonConfigHandlerTest method testConfigTest.

@Test
public void testConfigTest() {
    final CommonDistributionConfigActions configActions = Mockito.mock(CommonDistributionConfigActions.class);
    final CommonConfigHandler<CommonDistributionConfigEntity, CommonDistributionConfigRestModel, CommonDistributionRepositoryWrapper> handler = new CommonConfigHandler<>(CommonDistributionConfigEntity.class, CommonDistributionConfigRestModel.class, configActions, objectTransformer);
    final CommonDistributionConfigRestModel restModel = mockCommonDistributionRestModel.createRestModel();
    final ResponseEntity<String> response = handler.testConfig(restModel);
    assertEquals(HttpStatus.OK, response.getStatusCode());
}
Also used : CommonDistributionConfigActions(com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) Test(org.junit.Test)

Example 8 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper in project hub-alert by blackducksoftware.

the class CommonConfigHandlerTest method deleteConfigWithInvalidIdTest.

@Test
public void deleteConfigWithInvalidIdTest() {
    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.deleteConfig(restModel);
    assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
}
Also used : CommonDistributionConfigActions(com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) Test(org.junit.Test)

Example 9 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper 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());
}
Also used : CommonDistributionConfigActions(com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) Test(org.junit.Test)

Example 10 with CommonDistributionRepositoryWrapper

use of com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper 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);
}
Also used : CommonDistributionConfigActions(com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions) CommonDistributionRepositoryWrapper(com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper) CommonDistributionConfigRestModel(com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel) CommonDistributionConfigEntity(com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity) Test(org.junit.Test)

Aggregations

CommonDistributionRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.CommonDistributionRepositoryWrapper)25 Test (org.junit.Test)22 CommonDistributionConfigEntity (com.blackducksoftware.integration.hub.alert.datasource.entity.CommonDistributionConfigEntity)20 CommonDistributionConfigActions (com.blackducksoftware.integration.hub.alert.web.actions.distribution.CommonDistributionConfigActions)18 CommonDistributionConfigRestModel (com.blackducksoftware.integration.hub.alert.web.model.distribution.CommonDistributionConfigRestModel)18 AlertFieldException (com.blackducksoftware.integration.hub.alert.exception.AlertFieldException)5 AlertException (com.blackducksoftware.integration.hub.alert.exception.AlertException)4 AuditEntryRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditEntryRepositoryWrapper)3 ConfiguredProjectsRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.ConfiguredProjectsRepositoryWrapper)3 NotificationTypeRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.entity.repository.NotificationTypeRepositoryWrapper)3 DistributionNotificationTypeRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionNotificationTypeRepositoryWrapper)3 DistributionProjectRepositoryWrapper (com.blackducksoftware.integration.hub.alert.datasource.relation.repository.DistributionProjectRepositoryWrapper)3 ConfiguredProjectsActions (com.blackducksoftware.integration.hub.alert.web.actions.ConfiguredProjectsActions)3 NotificationTypesActions (com.blackducksoftware.integration.hub.alert.web.actions.NotificationTypesActions)3 IntegrationException (com.blackducksoftware.integration.exception.IntegrationException)2 NotificationManager (com.blackducksoftware.integration.hub.alert.NotificationManager)2 TestGlobalProperties (com.blackducksoftware.integration.hub.alert.TestGlobalProperties)2 MockAuditEntryEntity (com.blackducksoftware.integration.hub.alert.audit.mock.MockAuditEntryEntity)2 AuditNotificationRepositoryWrapper (com.blackducksoftware.integration.hub.alert.audit.repository.AuditNotificationRepositoryWrapper)2 EmailGroupChannel (com.blackducksoftware.integration.hub.alert.channel.email.EmailGroupChannel)2