@Test public void testFetchIf() throws IOException { Fongo fongo = new Fongo("Mongo DB"); Discoverer d = new Discoverer(fongo.getMongo()); ArrayList<String> offeringNames = new ArrayList<String>(); offeringNames.add("EC2"); offeringNames.add("Azure"); offeringNames.add("Openshift"); for (String name: offeringNames) { d.addOffering(new Offering(name)); } Offering of = new Offering("Example"); of.addProperty("num_cpus", "8"); d.addOffering(of); ArrayList<DiscovererAPI.OfferingRepresentation> offerings = (new DiscovererAPI(d)).getOfferingsIf("{ \"num_cpus\": \"8\" }"); Assert.assertEquals(offerings.size(), 1); String fetchedOffering = offerings.get(0).getOffering(); Assert.assertEquals(fetchedOffering, of.toTosca()); }
public String addOffering(Offering newOffering) { if (newOffering == null) return null; String offeringName = newOffering.getName(); if (offeringManager.getOffering(offeringName) != null) { offeringManager.removeOffering(offeringName); } offeringManager.addOffering(newOffering); this.offeringNodeTemplates.add(newOffering.getNodeTemplate()); totalCrawledOfferings++; return offeringName; }
Discoverer { public String addOffering(Offering newOffering) { if (newOffering == null) return null; String offeringName = newOffering.getName(); if (offeringManager.getOffering(offeringName) != null) { offeringManager.removeOffering(offeringName); } offeringManager.addOffering(newOffering); this.offeringNodeTemplates.add(newOffering.getNodeTemplate()); totalCrawledOfferings++; return offeringName; } }
Discoverer { public String addOffering(Offering newOffering) { if (newOffering == null) return null; String offeringName = newOffering.getName(); if (offeringManager.getOffering(offeringName) != null) { offeringManager.removeOffering(offeringName); } offeringManager.addOffering(newOffering); this.offeringNodeTemplates.add(newOffering.getNodeTemplate()); totalCrawledOfferings++; return offeringName; } Discoverer(MongoClient mongoClient, ArrayList<String> activeCrawlers);  Discoverer(MongoClient mongoClient); }
Discoverer { public String addOffering(Offering newOffering) { if (newOffering == null) return null; String offeringName = newOffering.getName(); if (offeringManager.getOffering(offeringName) != null) { offeringManager.removeOffering(offeringName); } offeringManager.addOffering(newOffering); this.offeringNodeTemplates.add(newOffering.getNodeTemplate()); totalCrawledOfferings++; return offeringName; } Discoverer(MongoClient mongoClient, ArrayList<String> activeCrawlers);  Discoverer(MongoClient mongoClient); synchronized void setRefreshing(boolean refreshing); synchronized boolean getRefreshing(); Offering fetchOffer(String cloudOfferingId); String addOffering(Offering newOffering); boolean removeOffering(String cloudOfferingId); Collection<String> getAllOfferingIds(); void generateSingleOffering(); void refreshRepository(); }
Discoverer { public String addOffering(Offering newOffering) { if (newOffering == null) return null; String offeringName = newOffering.getName(); if (offeringManager.getOffering(offeringName) != null) { offeringManager.removeOffering(offeringName); } offeringManager.addOffering(newOffering); this.offeringNodeTemplates.add(newOffering.getNodeTemplate()); totalCrawledOfferings++; return offeringName; } Discoverer(MongoClient mongoClient, ArrayList<String> activeCrawlers);  Discoverer(MongoClient mongoClient); synchronized void setRefreshing(boolean refreshing); synchronized boolean getRefreshing(); Offering fetchOffer(String cloudOfferingId); String addOffering(Offering newOffering); boolean removeOffering(String cloudOfferingId); Collection<String> getAllOfferingIds(); void generateSingleOffering(); void refreshRepository(); public int totalCrawledOfferings; public int crawledTimes; public Date lastCrawl; public OfferingManager offeringManager; }