### Question:
BonitaVersion { public String getVersion() { if (metadata == null) { metadata = read(file.getStream()); } if (metadata.size() > 0) { return metadata.get(0).trim(); } else { return ""; } } BonitaVersion(final VersionFile file); String getVersion(); String getCopyright();  }### Answer:
@Test public void should_read_version_stream_to_return_its_version() throws Exception { final InputStream stream = IOUtils.toInputStream("1.0.0"); given(file.getStream()).willReturn(stream); final BonitaVersion version = new BonitaVersion(file); assertThat(version.getVersion()).isEqualTo("1.0.0"); IOUtils.closeQuietly(stream); }
@Test public void should_trim_extra_new_line_character() throws Exception { final InputStream stream = IOUtils.toInputStream("1.0.0\n"); given(file.getStream()).willReturn(stream); final BonitaVersion version = new BonitaVersion(file); assertThat(version.getVersion()).isEqualTo("1.0.0"); IOUtils.closeQuietly(stream); }