Search in sources :

Example 1 with CustomCertificateRepository

use of com.synopsys.integration.alert.database.certificates.CustomCertificateRepository in project hub-alert by blackducksoftware.

the class DefaultCustomCertificateAccessorTest method storeCertificateIdDoesNotExistTest.

@Test
public void storeCertificateIdDoesNotExistTest() {
    CustomCertificateRepository customCertificateRepository = new MockCustomCertificateRepository();
    DefaultCustomCertificateAccessor customCertificateAccessor = new DefaultCustomCertificateAccessor(customCertificateRepository);
    try {
        CustomCertificateModel certificateModel = new CustomCertificateModel(9L, alias, content, testDate.toString());
        customCertificateAccessor.storeCertificate(certificateModel);
        fail();
    } catch (AlertConfigurationException e) {
        assertNotNull(e);
    }
}
Also used : CustomCertificateRepository(com.synopsys.integration.alert.database.certificates.CustomCertificateRepository) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) CustomCertificateModel(com.synopsys.integration.alert.common.persistence.model.CustomCertificateModel) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) AlertConfigurationException(com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException) Test(org.junit.jupiter.api.Test)

Example 2 with CustomCertificateRepository

use of com.synopsys.integration.alert.database.certificates.CustomCertificateRepository in project hub-alert by blackducksoftware.

the class DefaultCustomCertificateAccessorTest method getCertificatesTest.

@Test
public void getCertificatesTest() {
    CustomCertificateRepository customCertificateRepository = new MockCustomCertificateRepository(alias, content, testDate);
    DefaultCustomCertificateAccessor customCertificateAccessor = new DefaultCustomCertificateAccessor(customCertificateRepository);
    List<CustomCertificateModel> customCertificateModelList = customCertificateAccessor.getCertificates();
    assertEquals(1, customCertificateModelList.size());
    CustomCertificateModel customCertificateModel = customCertificateModelList.get(0);
    testCustomCertificateModel(expectedCustomCertificateModel, customCertificateModel);
}
Also used : CustomCertificateRepository(com.synopsys.integration.alert.database.certificates.CustomCertificateRepository) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) CustomCertificateModel(com.synopsys.integration.alert.common.persistence.model.CustomCertificateModel) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) Test(org.junit.jupiter.api.Test)

Example 3 with CustomCertificateRepository

use of com.synopsys.integration.alert.database.certificates.CustomCertificateRepository in project hub-alert by blackducksoftware.

the class DefaultCustomCertificateAccessorTest method getCertificateTest.

@Test
public void getCertificateTest() {
    CustomCertificateRepository customCertificateRepository = new MockCustomCertificateRepository(alias, content, testDate);
    DefaultCustomCertificateAccessor customCertificateAccessor = new DefaultCustomCertificateAccessor(customCertificateRepository);
    Optional<CustomCertificateModel> customCertificateModelOptional = customCertificateAccessor.getCertificate(0L);
    Optional<CustomCertificateModel> customCertificateModelOptionalEmpty = customCertificateAccessor.getCertificate(9L);
    assertTrue(customCertificateModelOptional.isPresent());
    assertFalse(customCertificateModelOptionalEmpty.isPresent());
    CustomCertificateModel customCertificateModel = customCertificateModelOptional.get();
    testCustomCertificateModel(expectedCustomCertificateModel, customCertificateModel);
}
Also used : CustomCertificateRepository(com.synopsys.integration.alert.database.certificates.CustomCertificateRepository) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) CustomCertificateModel(com.synopsys.integration.alert.common.persistence.model.CustomCertificateModel) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) Test(org.junit.jupiter.api.Test)

Example 4 with CustomCertificateRepository

use of com.synopsys.integration.alert.database.certificates.CustomCertificateRepository in project hub-alert by blackducksoftware.

the class DefaultCustomCertificateAccessorTest method deleteCertificateByIdTest.

@Test
public void deleteCertificateByIdTest() {
    CustomCertificateRepository customCertificateRepository = new MockCustomCertificateRepository(alias, content, testDate);
    DefaultCustomCertificateAccessor customCertificateAccessor = new DefaultCustomCertificateAccessor(customCertificateRepository);
    List<CustomCertificateModel> customCertificateModelList = customCertificateAccessor.getCertificates();
    assertEquals(1, customCertificateModelList.size());
    CustomCertificateModel customCertificateModel = customCertificateModelList.get(0);
    testCustomCertificateModel(expectedCustomCertificateModel, customCertificateModel);
    customCertificateAccessor.deleteCertificate(0L);
    customCertificateModelList = customCertificateAccessor.getCertificates();
    assertTrue(customCertificateModelList.isEmpty());
}
Also used : CustomCertificateRepository(com.synopsys.integration.alert.database.certificates.CustomCertificateRepository) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) CustomCertificateModel(com.synopsys.integration.alert.common.persistence.model.CustomCertificateModel) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) Test(org.junit.jupiter.api.Test)

Example 5 with CustomCertificateRepository

use of com.synopsys.integration.alert.database.certificates.CustomCertificateRepository in project hub-alert by blackducksoftware.

the class DefaultCustomCertificateAccessorTest method deleteCertificateByAliasTest.

@Test
public void deleteCertificateByAliasTest() {
    CustomCertificateRepository customCertificateRepository = new MockCustomCertificateRepository(alias, content, testDate);
    DefaultCustomCertificateAccessor customCertificateAccessor = new DefaultCustomCertificateAccessor(customCertificateRepository);
    List<CustomCertificateModel> customCertificateModelList = customCertificateAccessor.getCertificates();
    assertEquals(1, customCertificateModelList.size());
    CustomCertificateModel customCertificateModel = customCertificateModelList.get(0);
    testCustomCertificateModel(expectedCustomCertificateModel, customCertificateModel);
    customCertificateAccessor.deleteCertificate(alias);
    customCertificateModelList = customCertificateAccessor.getCertificates();
    assertTrue(customCertificateModelList.isEmpty());
}
Also used : CustomCertificateRepository(com.synopsys.integration.alert.database.certificates.CustomCertificateRepository) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) CustomCertificateModel(com.synopsys.integration.alert.common.persistence.model.CustomCertificateModel) MockCustomCertificateRepository(com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository) Test(org.junit.jupiter.api.Test)

Aggregations

CustomCertificateModel (com.synopsys.integration.alert.common.persistence.model.CustomCertificateModel)6 MockCustomCertificateRepository (com.synopsys.integration.alert.database.api.mock.MockCustomCertificateRepository)6 CustomCertificateRepository (com.synopsys.integration.alert.database.certificates.CustomCertificateRepository)6 Test (org.junit.jupiter.api.Test)6 AlertConfigurationException (com.synopsys.integration.alert.api.common.model.exception.AlertConfigurationException)1