X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fdatarouter%2Fpolicy%2FEntityEventPolicyStubbed.java;fp=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fdatarouter%2Fpolicy%2FEntityEventPolicyStubbed.java;h=9e10aee77b38bd329aeec964feabc12ed058a01e;hb=72da66902a3efaff3068ed2b3f4f7eb3bb5fe43f;hp=02f8ed7d2aa738c7c54bd4d45c413bd2e133e120;hpb=7753d7e90f5d91b143043a642e90dd30806da2ba;p=aai%2Fdata-router.git diff --git a/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyStubbed.java b/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyStubbed.java index 02f8ed7..9e10aee 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyStubbed.java +++ b/src/test/java/org/onap/aai/datarouter/policy/EntityEventPolicyStubbed.java @@ -27,30 +27,43 @@ import org.onap.aai.datarouter.policy.EntityEventPolicy; import org.onap.aai.datarouter.policy.EntityEventPolicyConfig; public class EntityEventPolicyStubbed extends EntityEventPolicy { - - - public EntityEventPolicyStubbed(EntityEventPolicyConfig 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 EntityEventPolicyStubbed(EntityEventPolicyConfig config) throws FileNotFoundException { + super(config); + + } + + public InMemorySearchDatastore getSearchDb() { + return searchDb; + } + + public EntityEventPolicyStubbed withSearchDb(InMemorySearchDatastore searchDb) { + this.searchDb = searchDb; + return this; + } + + 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) { + } + } }