UpgradeAPI extends APIService { void setUpgradeVersionLocation(String upgradeVersionLocation) { this.upgradeVersionLocation = upgradeVersionLocation; }  @PostConstruct void init(); @RequestMapping(value = "/api/upgrade/check", method = GET) @ApiOperation(value = "Checks if a newer versions are available and returns them as JSON.", produces = MediaType.APPLICATION_JSON_VALUE) @Timed @PublicAPI Stream<UpgradeServerVersion> check();  }
@Test public void checkWithoutUpgradeServer() throws Exception { upgradeAPI.setUpgradeVersionLocation(""); String actual = RestAssured.when().get("/api/upgrade/check").asString(); assertEquals("[]", actual, true); }
@Test public void checkUpgradeServerFailure() throws Exception { upgradeAPI.setUpgradeVersionLocation("http: String actual = RestAssured.when().get("/api/upgrade/check").asString(); assertEquals("[]", actual, true); }
@Test public void checkDynamicUpgradeServer() throws Exception { upgradeAPI.setUpgradeVersionLocation("http: String response = RestAssured.when().get("/api/upgrade/check").asString(); final List<UpgradeServerVersion> versions = mapper.readerFor(new TypeReference<List<UpgradeServerVersion>>() { }).readValue(response); assertEquals(1, versions.size()); final UpgradeServerVersion actual = versions.get(0); final String expectedVersion = versionService.version().getVersionId(); final String expectedToken = TokenGenerator.generateMachineToken(new CryptoHelper("DataPrepIsSoCool")); assertEquals(expectedToken, actual.getTitle()); assertEquals(expectedVersion, actual.getDownloadUrl()); }