SnapshotSourcePlugin extends AbstractEC2InstancePlugin { @Override protected void process(final EC2InstanceContext context) { context.getSource() .filter(string -> string.matches(SNAPSHOT_REGEX)) .ifPresent(source -> violationSink.put( context.violation() .withType(ViolationType.EC2_WITH_A_SNAPSHOT_IMAGE) .withPluginFullyQualifiedClassName(SnapshotSourcePlugin.class) .withMetaInfo(singletonMap("deployment_artifact", source)) .build())); } @Autowired  SnapshotSourcePlugin(final EC2InstanceContextProvider contextProvider, final ViolationSink violationSink);   }
@Test public void testMissingSource() throws Exception { when(mockContext.getSource()).thenReturn(Optional.empty()); plugin.process(mockContext); verify(mockContext).getSource(); }
@Test public void testFixVersion() throws Exception { when(mockContext.getSource()).thenReturn(Optional.of("docker: plugin.process(mockContext); verify(mockContext).getSource(); }
@Test public void testSnapshotInName() throws Exception { when(mockContext.getSource()).thenReturn(Optional.of("docker: plugin.process(mockContext); verify(mockContext).getSource(); }
@Test public void testSnapshotArtifact() throws Exception { when(mockContext.getSource()).thenReturn(Optional.of("docker: plugin.process(mockContext); verify(mockContext).getSource(); verify(mockContext).violation(); verify(mockViolationSink).put(argThat(hasType(EC2_WITH_A_SNAPSHOT_IMAGE))); }