■ ■ ■ ■ ■ ■
plugin/src/test/java/com/google/tsunami/plugin/PluginDefinitionTest.java
| skipped 17 lines |
18 | 18 | | import static com.google.common.truth.Truth.assertThat; |
19 | 19 | | import static org.junit.Assert.assertThrows; |
20 | 20 | | |
| 21 | + | import com.google.tsunami.plugin.annotations.PluginInfo; |
| 22 | + | import com.google.tsunami.plugin.testing.FakeRemoteVulnDetector; |
21 | 23 | | import com.google.tsunami.plugin.testing.FakeVulnDetector; |
22 | 24 | | import org.junit.Test; |
23 | 25 | | import org.junit.runner.RunWith; |
| skipped 7 lines |
31 | 33 | | public void id_always_generatesCorrectPluginId() { |
32 | 34 | | PluginDefinition pluginDefinition = PluginDefinition.forPlugin(FakeVulnDetector.class); |
33 | 35 | | |
34 | | - | assertThat(pluginDefinition.id()) |
35 | | - | .isEqualTo("/fake/VULN_DETECTION/FakeVulnDetector/v0.1"); |
| 36 | + | assertThat(pluginDefinition.id()).isEqualTo("/fake/VULN_DETECTION/FakeVulnDetector/v0.1"); |
36 | 37 | | } |
37 | 38 | | |
38 | 39 | | @Test |
39 | 40 | | public void forPlugin_whenPluginHasNoAnnotation_throwsException() { |
40 | 41 | | assertThrows( |
41 | 42 | | IllegalStateException.class, () -> PluginDefinition.forPlugin(NoAnnotationPlugin.class)); |
| 43 | + | } |
| 44 | + | |
| 45 | + | @Test |
| 46 | + | public void forRemotePlugin_always_generatesCorrectDefinition() { |
| 47 | + | PluginInfo pluginInfo = FakeRemoteVulnDetector.class.getAnnotation(PluginInfo.class); |
| 48 | + | PluginDefinition pluginDefinition = PluginDefinition.forRemotePlugin(pluginInfo); |
| 49 | + | |
| 50 | + | assertThat(pluginDefinition.pluginInfo()).isEqualTo(pluginInfo); |
| 51 | + | assertThat(pluginDefinition.id()) |
| 52 | + | .isEqualTo("/fake/REMOTE_VULN_DETECTION/FakeRemoteVulnDetector/v0.1"); |
| 53 | + | } |
| 54 | + | |
| 55 | + | @Test |
| 56 | + | public void forRemotePlugin_whenPassedNull_throwsException() { |
| 57 | + | assertThrows(NullPointerException.class, () -> PluginDefinition.forRemotePlugin(null)); |
42 | 58 | | } |
43 | 59 | | |
44 | 60 | | private static final class NoAnnotationPlugin implements TsunamiPlugin {} |
| skipped 2 lines |