HudsonBuildBuilder { HudsonBuild createHudsonBuild(Build build, Set<HudsonCommiter> commiters) { HudsonBuild hudsonBuild = new HudsonBuild(); hudsonBuild.setState(build.getResult()); hudsonBuild.setDuration(build.getDuration()); hudsonBuild.setStartTime(new Date(build.getTimestamp())); hudsonBuild.setSuccessful(HudsonXmlHelper.isSuccessful(build)); hudsonBuild.setCommiters(commiters); hudsonBuild.setBuildNumber(build.getNumber()); return hudsonBuild; }    }
@Test public void should_create_valid_hudson_build() { long duration = 123L; int buildNumber = 34; Set<HudsonCommiter> commiters = new TreeSet<HudsonCommiter>(); commiters.add(new HudsonCommiter("dude")); commiters.add(new HudsonCommiter("sweet")); Date startTime = new Date(); String state = null; List<Culprit> users = new ArrayList<Culprit>(); users.add(new Culprit()); users.add(new Culprit()); users.get(0).setFullName("dude"); users.get(1).setFullName("sweet"); MavenModuleSetBuild setBuild = mock(MavenModuleSetBuild.class); when(setBuild.getDuration()).thenReturn(duration); when(setBuild.getCulprits()).thenReturn(users); when(setBuild.getNumber()).thenReturn(buildNumber); when(setBuild.getTimestamp()).thenReturn(startTime.getTime()); HudsonBuildBuilder hudsonBuildBuilder = new HudsonBuildBuilder(); HudsonBuild hudsonBuild = hudsonBuildBuilder.createHudsonBuild(setBuild, commiters); assertEquals(duration, hudsonBuild.getDuration()); assertEquals(buildNumber, hudsonBuild.getBuildNumber()); assertEquals(commiters, hudsonBuild.getCommiters()); assertEquals(startTime, hudsonBuild.getStartTime()); assertEquals(state, hudsonBuild.getState()); }