X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fdatarouter%2Fpolicy%2FSpikeEntityEventPolicyStubbed.java;h=e0356a91748d1173383ba15ed81b1c5849ecd5c3;hb=72da66902a3efaff3068ed2b3f4f7eb3bb5fe43f;hp=17a76e86545553ee426253dbece8694d9b1a3bfe;hpb=7753d7e90f5d91b143043a642e90dd30806da2ba;p=aai%2Fdata-router.git diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyStubbed.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyStubbed.java index 17a76e8..e0356a9 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyStubbed.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntityEventPolicyStubbed.java @@ -25,30 +25,43 @@ import java.io.FileNotFoundException; import org.onap.aai.datarouter.entity.DocumentStoreDataEntity; public class SpikeEntityEventPolicyStubbed extends SpikeEntityEventPolicy { - - - public SpikeEntityEventPolicyStubbed(SpikeEntityEventPolicyConfig config) throws FileNotFoundException { - super(config); - - } - - protected void handleSearchServiceOperation(DocumentStoreDataEntity eventEntity, String action, String index) { - //Stub out the actual call to Search Data service and instead store/update documents in memory - try { - switch (action.toLowerCase()) { - case "create": - InMemorySearchDatastore.put(eventEntity.getId(), eventEntity.getAsJson()); // they are executed if variable == c1 - break; - case "update": - InMemorySearchDatastore.put(eventEntity.getId(), eventEntity.getAsJson()); // they are executed if variable == c1 - break; - case "delete": - InMemorySearchDatastore.remove(eventEntity.getId()); // they are executed if variable == c1 - break; - default: - break; - } - } catch (Exception ex) { - } - } + + private InMemorySearchDatastore searchDb; + + public SpikeEntityEventPolicyStubbed(SpikeEntityEventPolicyConfig config) + throws FileNotFoundException { + super(config); + } + + public SpikeEntityEventPolicyStubbed withSearchDb(InMemorySearchDatastore searchDb) { + this.searchDb = searchDb; + return this; + } + + public InMemorySearchDatastore getSearchDb() { + return searchDb; + } + + protected void handleSearchServiceOperation(DocumentStoreDataEntity eventEntity, String action, + String index) { + // Stub out the actual call to Search Data service and instead store/update documents in memory + try { + switch (action.toLowerCase()) { + case "create": + searchDb.put(eventEntity.getId(), eventEntity.getAsJson()); // they are executed if + // variable == c1 + break; + case "update": + searchDb.put(eventEntity.getId(), eventEntity.getAsJson()); // they are executed if + // variable == c1 + break; + case "delete": + searchDb.remove(eventEntity.getId()); // they are executed if variable == c1 + break; + default: + break; + } + } catch (Exception ex) { + } + } }