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) {
+ }
+ }
}