### Question:
EC2Plugin implements Plugin { @Override public Set<AWSLogReference> getLogReferences() { if (logReferences.isEmpty()) { populateLogReferences(); } return logReferences; } EC2Plugin();  EC2Plugin(FileSystem fs, EC2MetadataFetcher metadataFetcher); @Override boolean isEnabled(); @Override String getServiceName(); void populateRuntimeContext(); @Override Map<String, @Nullable Object> getRuntimeContext(); void populateLogReferences(); @Override Set<AWSLogReference> getLogReferences(); @Override String getOrigin(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); static final String ORIGIN; }### Answer:
@Test public void testFilePathCreationFailure() { List<Path> pathList = new ArrayList<>(); pathList.add(Paths.get("badRoot")); Mockito.doReturn(pathList).when(fakeFs).getRootDirectories(); Set<AWSLogReference> logReferences = ec2Plugin.getLogReferences(); assertThat(logReferences).isEmpty(); }
@Test public void testGenerationOfLogReference() throws IOException { List<Path> pathList = new ArrayList<>(); pathList.add(Paths.get("/")); Mockito.doReturn(pathList).when(fakeFs).getRootDirectories(); List<String> groupList = new ArrayList<>(); groupList.add("test_group"); BDDMockito.given(JsonUtils.getMatchingListFromJsonArrayNode(Mockito.any(), Mockito.any())).willReturn(groupList); Set<AWSLogReference> logReferences = ec2Plugin.getLogReferences(); assertThat(logReferences).hasOnlyOneElementSatisfying( reference -> assertThat(reference.getLogGroup()).isEqualTo("test_group")); }
@Test public void testGenerationOfMultipleLogReferences() throws IOException { List<Path> pathList = new ArrayList<>(); pathList.add(Paths.get("/")); Mockito.doReturn(pathList).when(fakeFs).getRootDirectories(); List<String> groupList = new ArrayList<>(); groupList.add("test_group1"); groupList.add("test_group2"); groupList.add("test_group1"); BDDMockito.given(JsonUtils.getMatchingListFromJsonArrayNode(Mockito.any(), Mockito.any())).willReturn(groupList); Set<AWSLogReference> logReferences = ec2Plugin.getLogReferences(); assertThat(logReferences).hasSize(2); }