AppCatalogSolrClient { public void upgradeApp(Service service) throws IOException, SolrServerException { ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); Collection<SolrInputDocument> docs = new HashSet<SolrInputDocument>(); SolrClient solr = getSolrClient(); if (service!=null) { String name = service.getName(); String app = ""; SolrQuery query = new SolrQuery(); query.setQuery("id:" + name); query.setFilterQueries("type_s:AppEntry"); query.setRows(1); QueryResponse response; try { response = solr.query(query); Iterator<SolrDocument> appList = response.getResults().listIterator(); while (appList.hasNext()) { SolrDocument d = appList.next(); app = d.get("app_s").toString(); } } catch (SolrServerException | IOException e) { LOG.error("Error in finding deployed application: " + name, e); } SolrInputDocument request = new SolrInputDocument(); request.addField("type_s", "AppEntry"); request.addField("id", name); request.addField("name_s", name); request.addField("app_s", app); request.addField("yarnfile_s", mapper.writeValueAsString(service)); docs.add(request); } try { commitSolrChanges(solr, docs); } catch (IOException e) { throw new IOException("Unable to register docker instance " + "with application entry.", e); } } AppCatalogSolrClient(); SolrClient getSolrClient(); List<AppStoreEntry> getRecommendedApps(); List<AppStoreEntry> search(String keyword); List<AppEntry> listAppEntries(); AppStoreEntry findAppStoreEntry(String id); AppEntry findAppEntry(String id); void deployApp(String id, Service service); void deleteApp(String id); void register(Application app); void upgradeApp(Service service);  }
@Test public void testUpgradeApp() throws Exception { Application example = new Application(); String expected = "2.0"; String actual = ""; example.setOrganization("jenkins-ci.org"); example.setVersion("1.0"); example.setName("jenkins"); example.setDescription("World leading open source automation system."); example.setIcon("/css/img/feather.png"); spy.register(example); spy.deployApp("test", example); example.setVersion("2.0"); spy.upgradeApp(example); List<AppEntry> appEntries = spy.listAppEntries(); actual = appEntries.get(appEntries.size() -1).getYarnfile().getVersion(); assertEquals(expected, actual); }