AppCatalogSolrClient { public void register(Application app) throws IOException { Collection<SolrInputDocument> docs = new HashSet<SolrInputDocument>(); SolrClient solr = getSolrClient(); ObjectMapper mapper = new ObjectMapper(); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); try { SolrInputDocument buffer = new SolrInputDocument(); buffer.setField("id", java.util.UUID.randomUUID().toString() .substring(0, 11)); buffer.setField("org_s", app.getOrganization()); buffer.setField("name_s", app.getName()); buffer.setField("desc_s", app.getDescription()); if (app.getIcon() != null) { buffer.setField("icon_s", app.getIcon()); } buffer.setField("type_s", "AppStoreEntry"); buffer.setField("like_i", 0); buffer.setField("download_i", 0); String yarnFile = mapper.writeValueAsString(app); LOG.info("app:"+yarnFile); Service yarnApp = mapper.readValue(yarnFile, Service.class); buffer.setField("yarnfile_s", mapper.writeValueAsString(yarnApp)); docs.add(buffer); commitSolrChanges(solr, docs); } catch (SolrServerException | IOException e) { throw new IOException("Unable to register application " + "in Application Store. ", 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 testRegister() throws Exception { Application example = new Application(); example.setOrganization("jenkins-ci.org"); example.setName("jenkins"); example.setDescription("World leading open source automation system."); example.setIcon("/css/img/feather.png"); spy.register(example); List<AppStoreEntry> apps = spy.getRecommendedApps(); assertEquals(1, apps.size()); }