X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Fonap%2Faai%2Fdatarouter%2Fpolicy%2FSpikeEntitySearchProcessorStubbed.java;h=5c82c4dc785036a09f954938c46d1bf38efc9188;hb=72da66902a3efaff3068ed2b3f4f7eb3bb5fe43f;hp=100ff0a977b880c2a48eddc1d16af87f5919b72e;hpb=7753d7e90f5d91b143043a642e90dd30806da2ba;p=aai%2Fdata-router.git diff --git a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorStubbed.java b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorStubbed.java index 100ff0a..5c82c4d 100644 --- a/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorStubbed.java +++ b/src/test/java/org/onap/aai/datarouter/policy/SpikeEntitySearchProcessorStubbed.java @@ -25,30 +25,44 @@ import java.io.FileNotFoundException; import org.onap.aai.datarouter.entity.DocumentStoreDataEntity; public class SpikeEntitySearchProcessorStubbed extends SpikeEntitySearchProcessor { - - - public SpikeEntitySearchProcessorStubbed(SpikeEventPolicyConfig 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 SpikeEntitySearchProcessorStubbed(SpikeEventPolicyConfig config) + throws FileNotFoundException { + super(config); + } + + public SpikeEntitySearchProcessorStubbed 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) { + } + } }