use of com.blackducksoftware.integration.test.TestLogger in project hub-alert by blackducksoftware.
the class NotificationItemProcessorTest method testInit.
@Test
public void testInit() {
final GlobalProperties globalProperties = new TestGlobalProperties();
final NotificationItemProcessor notificationItemProcessor = new NotificationItemProcessor(globalProperties, new TestLogger());
assertTrue(notificationItemProcessor.getCacheList().size() == 2);
assertTrue(notificationItemProcessor.getProcessorMap().size() == 4);
}
use of com.blackducksoftware.integration.test.TestLogger in project hub-alert by blackducksoftware.
the class PolicyViolationClearedProcessorTest method testProcess.
@Test
public void testProcess() throws URISyntaxException, HubIntegrationException {
final MapProcessorCache cache = new MapProcessorCache();
final PolicyViolationClearedProcessor policyViolationClearedProcessor = new PolicyViolationClearedProcessor(cache, new TestLogger());
final Date createdAt = new Date();
final ProjectVersionModel projectVersionModel = new ProjectVersionModel();
final String componentName = "Content item test";
final ComponentVersionView componentVersionView = new ComponentVersionView();
final String componentUrl = "url";
final String componentVersionUrl = "newest";
final PolicyRuleView policyRuleView = new PolicyRuleView();
final List<PolicyRuleView> policyRuleList = Arrays.asList(policyRuleView);
final String componentIssueUrl = "broken.edu";
final PolicyViolationClearedContentItem notification = new PolicyViolationClearedContentItem(createdAt, projectVersionModel, componentName, componentVersionView, componentUrl, componentVersionUrl, policyRuleList, componentIssueUrl);
assertTrue(cache.getEvents().size() == 0);
final PolicyViolationClearedProcessor spyProcessor = Mockito.spy(policyViolationClearedProcessor);
Mockito.doReturn("key").when(spyProcessor).generateEventKey(Mockito.anyMap());
spyProcessor.process(notification);
assertTrue(cache.getEvents().size() == 1);
spyProcessor.process(notification);
assertTrue(cache.getEvents().size() == 0);
}
use of com.blackducksoftware.integration.test.TestLogger in project hub-alert by blackducksoftware.
the class VulnerabilityProcessorTest method testProcess.
@Test
public void testProcess() throws URISyntaxException, HubIntegrationException {
final MapProcessorCache cache = new MapProcessorCache();
final VulnerabilityProcessor vulnProcessor = new VulnerabilityProcessor(cache, new TestLogger());
final Date createdAt = new Date();
final ProjectVersionModel projectVersionModel = new ProjectVersionModel();
projectVersionModel.setProjectLink("New project link");
final String componentName = "notification test";
final ComponentVersionView componentVersionView = new ComponentVersionView();
final String componentVersionUrl = "sss";
final String componentIssueUrl = "ddd";
final List<VulnerabilitySourceQualifiedId> addedVulns = Lists.newArrayList();
final List<VulnerabilitySourceQualifiedId> updatedVulns = Lists.newArrayList();
final List<VulnerabilitySourceQualifiedId> deletedVulns = Lists.newArrayList();
final VulnerabilityContentItem emptyVulnerabilityContentItem = new VulnerabilityContentItem(createdAt, projectVersionModel, componentName, componentVersionView, componentVersionUrl, addedVulns, updatedVulns, deletedVulns, componentIssueUrl);
vulnProcessor.process(emptyVulnerabilityContentItem);
assertTrue(cache.getEvents().size() == 0);
final VulnerabilitySourceQualifiedId addedQualifiedId = new VulnerabilitySourceQualifiedId();
final VulnerabilitySourceQualifiedId removedQualifiedId = new VulnerabilitySourceQualifiedId();
addedVulns.add(addedQualifiedId);
updatedVulns.add(addedQualifiedId);
deletedVulns.add(removedQualifiedId);
final VulnerabilityContentItem filledAndEmptiedVulnerabilityContentItem = new VulnerabilityContentItem(createdAt, projectVersionModel, componentName, componentVersionView, componentVersionUrl, addedVulns, updatedVulns, deletedVulns, componentIssueUrl);
vulnProcessor.process(filledAndEmptiedVulnerabilityContentItem);
assertTrue(cache.getEvents().size() == 0);
}
use of com.blackducksoftware.integration.test.TestLogger in project hub-alert by blackducksoftware.
the class PolicyOverrideProcessorTest method testProcessRemoveEvent.
@Test
public void testProcessRemoveEvent() throws HubIntegrationException, URISyntaxException {
// Test will break if ListProcessorCache is used because NotificationEvents does not have an equals method defined
final MapProcessorCache cache = new MapProcessorCache();
final PolicyOverrideProcessor policyOverrideProcessor = new PolicyOverrideProcessor(cache, new TestLogger());
final Date createdAt = new Date();
final ProjectVersionModel projectVersionModel = new ProjectVersionModel();
final String componentName = "Content item test";
final ComponentVersionView componentVersionView = new ComponentVersionView();
final String componentUrl = "google.com";
final String componentVersionUrl = "newest";
final PolicyRuleView policyRuleView = new PolicyRuleView();
final List<PolicyRuleView> policyRuleList = Arrays.asList(policyRuleView);
final String firstName = "B";
final String lastName = "Dawg";
final String componentIssueUrl = "broken.edu";
final PolicyOverrideContentItem notification = new PolicyOverrideContentItem(createdAt, projectVersionModel, componentName, componentVersionView, componentUrl, componentVersionUrl, policyRuleList, firstName, lastName, componentIssueUrl);
assertTrue(cache.getEvents().size() == 0);
final PolicyOverrideProcessor spyProcessor = Mockito.spy(policyOverrideProcessor);
Mockito.doReturn("key").when(spyProcessor).generateEventKey(Mockito.anyMap());
spyProcessor.process(notification);
assertTrue(cache.getEvents().size() == 1);
spyProcessor.process(notification);
assertTrue(cache.getEvents().size() == 0);
}
use of com.blackducksoftware.integration.test.TestLogger in project hub-alert by blackducksoftware.
the class PolicyViolationProcessorTest method processTestRun.
private void processTestRun(final PolicyViolationContentItem contentItem) throws HubIntegrationException {
final MapProcessorCache cache = new MapProcessorCache();
final PolicyViolationProcessor policyViolationProcessor = new PolicyViolationProcessor(cache, new TestLogger());
assertTrue(cache.getEvents().size() == 0);
policyViolationProcessor.process(contentItem);
assertTrue(cache.getEvents().size() == 1);
}
Aggregations