### Question:
BuildDAOImpl implements BuildDAO { String serializeResult(BuildResult buildResult, String userName, Pair<Long, Integer> when, ObjectId logSha1) throws UnsupportedEncodingException { StringBuilder content = new StringBuilder(); content.append("build ").append(buildResult.getCommitSha1()).append(NL); content.append("log ").append(logSha1.name()).append(NL); content.append("return-code ").append(buildResult.getExitCode()).append(NL); content.append("author ").append(userName).append(NL); content.append("when ").append(when.getT()).append(" ").append(timeService.offsetToString(when.getU())).append(NL); return content.toString(); } @Inject  BuildDAOImpl(GitUtils gitUtils, TimeService timeService); @Override BuildResult getLast(Repository repo, String sha1); @Override List<BuildResult> getAll(Repository repo, String sha1); @Override void save(BuildResult buildResult, Repository repo, String userName, Pair<Long,Integer> when);  }### Answer:
@Test public void testSerializeBuildResult_nominal() throws Exception { final BuildResult buildResult = new BuildResult(SHA1); buildResult.setStartDate(date(2011, Calendar.SEPTEMBER, 7, 1, 18, 35)); buildResult.setExitCode(3); buildResult.setLog("Oh. Yeah.".getBytes("UTF-8")); final Pair<Long, Integer> when = new Pair<Long, Integer>(123450000000L, 120); final String who = misterExample.toString(); final ObjectId logs = ObjectId.fromString("c4f3b4b3c4f3b4b3c4f3b4b3c4f3b4b3c4f3b4b3"); given(time.offsetToString(120)).willReturn("+0200"); String text = dao.serializeResult(buildResult, who, when, logs); assertThat(text).isEqualTo( "build 12345" + "\n" + "log c4f3b4b3c4f3b4b3c4f3b4b3c4f3b4b3c4f3b4b3" + "\n" + "return-code 3" + "\n" + "author \"Mister Example\" <user@example.org>" + "\n" + "when 123450000000 +0200\n" ); }