public void upgradeApp(Service service) throws IOException,
      SolrServerException {
    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);
      }
      // Register deployed application instance with AppList
      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", OBJECT_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);
    }
  }
@Test
  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);
  }