MessageFileCounter { public int getCountOfMessages() { int result; getMessagesFolderPath(); try { File folder = new File(messagesFolderPath); folder = folder.getAbsoluteFile(); result = folder.listFiles().length; } catch (NullPointerException e) { logger.debug(FOLDER_ERROR_MESSAGE, e); result = 0; } return result; }  int getCountOfMessages();  }
@Test public void testGetCountOfMessages() { int result = underTest.getCountOfMessages(); Assert.assertEquals(result, 2); }
@Test public void testGetCountOfMessagesShouldReturnWithZeroWhenTheMessageFolderDoesNotExists() { given(propertyHolder.get("log.folder")).willReturn("src/test/resources/something"); int result = underTest.getCountOfMessages(); Assert.assertEquals(result, 0); }