Search in sources :

Example 1 with MockEmailGlobalRestModel

use of com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel in project hub-alert by blackducksoftware.

the class GlobalEmailConfigActionsTest method testInvalidConfig.

@Override
public void testInvalidConfig() {
    final MockEmailGlobalRestModel mockUtil = new MockEmailGlobalRestModel();
    mockUtil.setMailSmtpPort("qq");
    mockUtil.setMailSmtpConnectionTimeout("qq");
    mockUtil.setMailSmtpTimeout("qq");
    mockUtil.setMailSmtpEhlo(false);
    mockUtil.setMailSmtpAuth(true);
    mockUtil.setMailSmtpAllow8bitmime(false);
    mockUtil.setMailSmtpSendPartial(false);
    final GlobalEmailConfigRestModel restModel = mockUtil.createGlobalRestModel();
    String result = null;
    try {
        result = configActions.validateConfig(restModel);
        fail();
    } catch (final AlertFieldException e) {
        assertTrue(true);
    }
    assertNull(result);
}
Also used : MockEmailGlobalRestModel(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel) AlertFieldException(com.blackducksoftware.integration.hub.alert.exception.AlertFieldException)

Example 2 with MockEmailGlobalRestModel

use of com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel in project hub-alert by blackducksoftware.

the class ObjectTransformerTest method testTransformNullModels.

@Test
public void testTransformNullModels() throws Exception {
    final MockEmailGlobalRestModel restGlobalEmailMockUtil = new MockEmailGlobalRestModel();
    final MockEmailGlobalEntity mockEmailGlobalEntity = new MockEmailGlobalEntity();
    final ObjectTransformer objectTransformer = new ObjectTransformer();
    GlobalEmailConfigEntity transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(null, GlobalEmailConfigEntity.class);
    GlobalEmailConfigRestModel transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(null, GlobalEmailConfigRestModel.class);
    assertNull(transformedConfigRestModel);
    assertNull(transformedConfigEntity);
    transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(restGlobalEmailMockUtil.createGlobalRestModel(), null);
    transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(mockEmailGlobalEntity.createGlobalEntity(), null);
    assertNull(transformedConfigRestModel);
    assertNull(transformedConfigEntity);
    transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(null, null);
    transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(null, null);
    assertNull(transformedConfigRestModel);
    assertNull(transformedConfigEntity);
}
Also used : GlobalEmailConfigEntity(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity) MockEmailGlobalRestModel(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel) MockEmailGlobalEntity(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalEntity) GlobalEmailConfigRestModel(com.blackducksoftware.integration.hub.alert.channel.email.controller.global.GlobalEmailConfigRestModel) Test(org.junit.Test)

Example 3 with MockEmailGlobalRestModel

use of com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel in project hub-alert by blackducksoftware.

the class ObjectTransformerTest method testTransformListsOfModels.

@Test
public void testTransformListsOfModels() throws Exception {
    final MockEmailGlobalRestModel restGlobalEmailMockUtil = new MockEmailGlobalRestModel();
    final MockEmailGlobalEntity mockEmailGlobalEntity = new MockEmailGlobalEntity();
    final ObjectTransformer objectTransformer = new ObjectTransformer();
    final GlobalEmailConfigRestModel restModel = restGlobalEmailMockUtil.createGlobalRestModel();
    final GlobalEmailConfigEntity configEntity = mockEmailGlobalEntity.createGlobalEntity();
    List<GlobalEmailConfigEntity> transformedConfigEntities = objectTransformer.configRestModelsToDatabaseEntities(Arrays.asList(restModel), GlobalEmailConfigEntity.class);
    List<GlobalEmailConfigRestModel> transformedConfigRestModels = objectTransformer.databaseEntitiesToConfigRestModels(Arrays.asList(configEntity), GlobalEmailConfigRestModel.class);
    assertNotNull(transformedConfigEntities);
    assertNotNull(transformedConfigRestModels);
    assertTrue(transformedConfigEntities.size() == 1);
    assertTrue(transformedConfigRestModels.size() == 1);
    assertEquals(restModel, transformedConfigRestModels.get(0));
    assertEquals(configEntity, transformedConfigEntities.get(0));
    transformedConfigEntities = objectTransformer.configRestModelsToDatabaseEntities(null, GlobalEmailConfigEntity.class);
    transformedConfigRestModels = objectTransformer.databaseEntitiesToConfigRestModels(null, GlobalEmailConfigRestModel.class);
}
Also used : GlobalEmailConfigEntity(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity) MockEmailGlobalRestModel(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel) MockEmailGlobalEntity(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalEntity) GlobalEmailConfigRestModel(com.blackducksoftware.integration.hub.alert.channel.email.controller.global.GlobalEmailConfigRestModel) Test(org.junit.Test)

Example 4 with MockEmailGlobalRestModel

use of com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel in project hub-alert by blackducksoftware.

the class ObjectTransformerTest method testTransformEmailModels.

@Test
public void testTransformEmailModels() throws Exception {
    final MockEmailGlobalRestModel restGlobalEmailMockUtil = new MockEmailGlobalRestModel();
    final MockEmailGlobalEntity mockEmailGlobalEntity = new MockEmailGlobalEntity();
    final ObjectTransformer objectTransformer = new ObjectTransformer();
    final GlobalEmailConfigRestModel restModel = restGlobalEmailMockUtil.createGlobalRestModel();
    final GlobalEmailConfigEntity configEntity = mockEmailGlobalEntity.createGlobalEntity();
    final GlobalEmailConfigEntity transformedConfigEntity = objectTransformer.configRestModelToDatabaseEntity(restModel, GlobalEmailConfigEntity.class);
    final GlobalEmailConfigRestModel transformedConfigRestModel = objectTransformer.databaseEntityToConfigRestModel(configEntity, GlobalEmailConfigRestModel.class);
    assertEquals(restModel, transformedConfigRestModel);
    assertEquals(configEntity, transformedConfigEntity);
}
Also used : GlobalEmailConfigEntity(com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity) MockEmailGlobalRestModel(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel) MockEmailGlobalEntity(com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalEntity) GlobalEmailConfigRestModel(com.blackducksoftware.integration.hub.alert.channel.email.controller.global.GlobalEmailConfigRestModel) Test(org.junit.Test)

Aggregations

MockEmailGlobalRestModel (com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalRestModel)4 GlobalEmailConfigRestModel (com.blackducksoftware.integration.hub.alert.channel.email.controller.global.GlobalEmailConfigRestModel)3 MockEmailGlobalEntity (com.blackducksoftware.integration.hub.alert.channel.email.mock.MockEmailGlobalEntity)3 GlobalEmailConfigEntity (com.blackducksoftware.integration.hub.alert.channel.email.repository.global.GlobalEmailConfigEntity)3 Test (org.junit.Test)3 AlertFieldException (com.blackducksoftware.integration.hub.alert.exception.AlertFieldException)1