### Question:
BuildPropertiesReader { public List<BuildProperties> getAllBuildProperties() { readAllBuildProperties(); return allBuildProperties; } BuildPropertiesReader(String buildPropertiesFile); BuildProperties getFirstServiceBuildProperties(); List<BuildProperties> getNonServiceBuildProperties(); List<BuildProperties> getAllBuildProperties(); void setResourceRetriever(ResourceRetriever resourcesRetriever);  }### Answer:
@Test public void testBuildPropertyInvalid() throws Exception { List<InputStream> testResourceStreams = new LinkedList<>(); testResourceStreams.add( new ByteArrayInputStream(getKeyValue(BuildProperties.BUILD_NAME_PROP, "sample").getBytes())); doReturn(testResourceStreams).when(mockResourceRetriever).getResources(any(), anyString()); List<BuildProperties> result = buildPropertiesReader.getAllBuildProperties(); Assert.assertEquals(result.size(), 1); Assert.assertFalse(result.get(0).isValid()); }
@Test public void testNullBuildPropertyStream() throws Exception { List<InputStream> testResourceStreams = new LinkedList<>(); testResourceStreams.add(null); doReturn(testResourceStreams).when(mockResourceRetriever).getResources(any(), anyString()); List<BuildProperties> result = buildPropertiesReader.getAllBuildProperties(); Assert.assertEquals(result.size(), 0); }
@Test(dataProvider = "PropertiesCountProvider") public void testGetAllBuildProperties(final int SERVICE_PROPERTIES_COUNT, final int NON_SERVICE_PROPERTIES_COUNT) throws Exception { generateResourceContents(SERVICE_PROPERTIES_COUNT, NON_SERVICE_PROPERTIES_COUNT); List<BuildProperties> result = buildPropertiesReader.getAllBuildProperties(); Assert.assertEquals(result.size(), SERVICE_PROPERTIES_COUNT + NON_SERVICE_PROPERTIES_COUNT); assertAllPropertiesValid(result); }
@Test public void throwExceptionOnRetrieve() throws Exception { doThrow(new RuntimeException()).when(mockResourceRetriever).getResources(any(), anyString()); buildPropertiesReader.getAllBuildProperties(); }