UtilHandler { @GET @Path("/getVersion") @Produces(TEXT_PLAIN) public String getVersion() { String currentVersion = versionManager.getCurrentVersion(); return currentVersion != null ? currentVersion : "alpha"; } @Inject  UtilHandler(final VersionManager versionManager); @GET @Path("/getVersion") @Produces(TEXT_PLAIN) String getVersion(); @GET @Path("/getReleaseInfo") @Produces(APPLICATION_JSON) ReleaseInfo getReleaseInfo(); @POST @Path("/getChildFolders") @Produces(APPLICATION_JSON) Collection<Folder> getChildFolders(@FormParam("path") final String parentPath);  }
@Test public void testGetVersion() { VersionManager versionManager = createMock(VersionManager.class); expect(versionManager.getCurrentVersion()).andReturn("version"); replay(versionManager); UtilHandler utilHandler = new UtilHandler(versionManager); String version = utilHandler.getVersion(); assertNotNull(version); assertEquals(version, "version"); verify(versionManager); }
@Test public void testGetNullVersion() { VersionManager versionManager = createMock(VersionManager.class); expect(versionManager.getCurrentVersion()).andReturn(null); replay(versionManager); UtilHandler utilHandler = new UtilHandler(versionManager); String version = utilHandler.getVersion(); assertNotNull(version); assertEquals(version, "alpha"); verify(versionManager); }