diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2019-04-05 21:07:07 -0400 |
---|---|---|
committer | Pamela Dragosh <pdragosh@research.att.com> | 2019-04-08 10:42:22 -0400 |
commit | ada55be1b59899e461dc5177782e381f89cbc407 (patch) | |
tree | 7bdb3eb5fe44e166a75a3333bf81f2293a3585de /models-interactions/model-impl/so/src/test | |
parent | eb7127ac85b3df30a09277721a5f9271033843e7 (diff) |
Remove drools PDP dependency
Removing working memory and use of PolicyEngine from
drools in these classes.
Cleaned up some unused imports and checkstyle.
Issue-ID: POLICY-1264
Change-Id: Id059da9689a721b0eafc6b310adcbdad43574ce7
Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'models-interactions/model-impl/so/src/test')
2 files changed, 35 insertions, 354 deletions
diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/DummyWorkingMemory.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/DummyWorkingMemory.java deleted file mode 100644 index caffef43d..000000000 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/DummyWorkingMemory.java +++ /dev/null @@ -1,316 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -import org.drools.core.WorkingMemory; -import org.drools.core.WorkingMemoryEntryPoint; -import org.drools.core.common.InternalFactHandle; -import org.drools.core.impl.InternalKnowledgeBase; -import org.drools.core.spi.AsyncExceptionHandler; -import org.drools.core.spi.GlobalResolver; -import org.kie.api.event.kiebase.KieBaseEventListener; -import org.kie.api.event.rule.AgendaEventListener; -import org.kie.api.event.rule.RuleRuntimeEventListener; -import org.kie.api.runtime.Environment; -import org.kie.api.runtime.ObjectFilter; -import org.kie.api.runtime.process.ProcessInstance; -import org.kie.api.runtime.process.WorkItemManager; -import org.kie.api.runtime.rule.Agenda; -import org.kie.api.runtime.rule.AgendaFilter; -import org.kie.api.runtime.rule.FactHandle; -import org.kie.api.runtime.rule.FactHandle.State; -import org.kie.api.runtime.rule.QueryResults; -import org.kie.api.time.SessionClock; - -public class DummyWorkingMemory implements WorkingMemory { - - @Override - public void addEventListener(RuleRuntimeEventListener listener) { - } - - @Override - public void addEventListener(AgendaEventListener listener) { - } - - @Override - public void addEventListener(KieBaseEventListener listener) { - } - - @Override - public void removeEventListener(RuleRuntimeEventListener listener) { - } - - @Override - public void removeEventListener(AgendaEventListener listener) { - } - - @Override - public void removeEventListener(KieBaseEventListener listener) { - } - - @Override - public Collection<RuleRuntimeEventListener> getRuleRuntimeEventListeners() { - return null; - } - - @Override - public Collection<AgendaEventListener> getAgendaEventListeners() { - return null; - } - - @Override - public Collection<KieBaseEventListener> getKieBaseEventListeners() { - return null; - } - - @Override - public FactHandle insert(Object object, boolean dynamic) { - return null; - } - - @Override - public FactHandle insert(Object object) { - return null; - } - - @Override - public void dispose() { - } - - @Override - public String getEntryPointId() { - return null; - } - - @Override - public void retract(FactHandle handle) { - } - - @Override - public void delete(FactHandle handle) { - } - - @Override - public void delete(FactHandle handle, State fhState) { - - - } - - @Override - public void update(FactHandle handle, Object object) { - } - - @Override - public void update(FactHandle handle, Object object, String... modifiedProperties) { - } - - @Override - public Collection<? extends Object> getObjects() { - return null; - } - - @Override - public Collection<? extends Object> getObjects(ObjectFilter filter) { - return null; - } - - @Override - public <T extends FactHandle> Collection<T> getFactHandles() { - return null; - } - - @Override - public <T extends FactHandle> Collection<T> getFactHandles(ObjectFilter filter) { - return null; - } - - @Override - public long getFactCount() { - return 0; - } - - @Override - public Agenda getAgenda() { - return null; - } - - @Override - public void setGlobal(String identifier, Object value) { - } - - @Override - public Object getGlobal(String identifier) { - return null; - } - - @Override - public Environment getEnvironment() { - return null; - } - - @Override - public void setGlobalResolver(GlobalResolver globalResolver) { - } - - @Override - public GlobalResolver getGlobalResolver() { - return null; - } - - @Override - public InternalKnowledgeBase getKnowledgeBase() { - return null; - } - - @Override - public int fireAllRules() { - return 0; - } - - @Override - public int fireAllRules(AgendaFilter agendaFilter) { - return 0; - } - - @Override - public int fireAllRules(int fireLimit) { - return 0; - } - - @Override - public int fireAllRules(AgendaFilter agendaFilter, int fireLimit) { - return 0; - } - - @Override - public Object getObject(FactHandle handle) { - return null; - } - - @Override - public FactHandle getFactHandle(Object object) { - return null; - } - - @Override - public FactHandle getFactHandleByIdentity(Object object) { - return null; - } - - @Override - public Iterator<?> iterateObjects() { - return null; - } - - @Override - public Iterator<?> iterateObjects(ObjectFilter filter) { - return null; - } - - @Override - public Iterator<InternalFactHandle> iterateFactHandles() { - return null; - } - - @Override - public Iterator<InternalFactHandle> iterateFactHandles(ObjectFilter filter) { - return null; - } - - @Override - public void setFocus(String focus) { - } - - @Override - public QueryResults getQueryResults(String query, Object... arguments) { - return null; - } - - @Override - public void setAsyncExceptionHandler(AsyncExceptionHandler handler) { - } - - @Override - public void clearAgenda() { - } - - @Override - public void clearAgendaGroup(String group) { - } - - @Override - public void clearActivationGroup(String group) { - } - - @Override - public void clearRuleFlowGroup(String group) { - } - - @Override - public ProcessInstance startProcess(String processId) { - return null; - } - - @Override - public ProcessInstance startProcess(String processId, Map<String, Object> parameters) { - return null; - } - - @Override - public Collection<ProcessInstance> getProcessInstances() { - return null; - } - - @Override - public ProcessInstance getProcessInstance(long id) { - return null; - } - - @Override - public ProcessInstance getProcessInstance(long id, boolean readOnly) { - return null; - } - - @Override - public WorkItemManager getWorkItemManager() { - return null; - } - - @Override - public void halt() { - } - - @Override - public WorkingMemoryEntryPoint getWorkingMemoryEntryPoint(String id) { - return null; - } - - @Override - public SessionClock getSessionClock() { - return null; - } - -} diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java index 4d7228ff7..03ac06dd5 100644 --- a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java +++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java @@ -40,16 +40,15 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; -import org.drools.core.WorkingMemory; import org.glassfish.grizzly.http.server.HttpServer; import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; import org.glassfish.jersey.server.ResourceConfig; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.so.SoManager.SoCallback; -public class SoManagerTest { +public class SoManagerTest implements SoCallback { private static final String BASE_URI = "http://localhost:46553/TestSOManager"; private static final String BASE_SO_URI = BASE_URI + "/SO"; private static HttpServer server; @@ -86,7 +85,7 @@ public class SoManagerTest { @Test public void testServiceInstantiation() throws IOException { - SoManager manager = new SoManager(); + SoManager manager = new SoManager(null, null, null); assertNotNull(manager); manager.setRestGetTimeout(100); @@ -161,19 +160,13 @@ public class SoManagerTest { @Test public void testVfModuleCreation() throws IOException { - SoManager manager = new SoManager(); + SoManager manager = new SoManager("http:/localhost:99999999", "sean", "citizen"); assertNotNull(manager); manager.setRestGetTimeout(100); - PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); - PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); - - WorkingMemory wm = new DummyWorkingMemory(); - SoRequest soRequest = new SoRequest(); soRequest.setOperationType(SoOperationType.SCALE_OUT); - PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); - Future<SoResponse> asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, + Future<SoResponse> asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); try { SoResponse response = asyncRestCallFuture.get(); @@ -182,8 +175,9 @@ public class SoManagerTest { fail("test should not throw an exception"); } - PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + manager = new SoManager(BASE_SO_URI, "sean", "citizen"); + manager.setRestGetTimeout(100); + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); try { SoResponse response = asyncRestCallFuture.get(); @@ -201,7 +195,7 @@ public class SoManagerTest { request.getRequestStatus().setRequestState("ONGOING"); request.setOperationType(SoOperationType.SCALE_OUT); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -212,7 +206,7 @@ public class SoManagerTest { request.setRequestType("ReturnCompleted"); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -222,7 +216,7 @@ public class SoManagerTest { } request.setRequestType("ReturnFailed"); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -235,7 +229,7 @@ public class SoManagerTest { request.setRequestType("ReturnOnging200"); request.setRequestScope(new Integer(10).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -247,7 +241,7 @@ public class SoManagerTest { request.setRequestType("ReturnOnging202"); request.setRequestScope(new Integer(20).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -260,7 +254,7 @@ public class SoManagerTest { // Test timeout after 20 attempts for a response request.setRequestType("ReturnOnging202"); request.setRequestScope(new Integer(21).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -272,7 +266,7 @@ public class SoManagerTest { // Test bad response after 3 attempts for a response request.setRequestType("ReturnBadAfterWait"); request.setRequestScope(new Integer(3).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -284,19 +278,13 @@ public class SoManagerTest { @Test public void testVfModuleDeletion() { - SoManager manager = new SoManager(); + SoManager manager = new SoManager("http:/localhost:99999999", "sean", "citizen"); assertNotNull(manager); manager.setRestGetTimeout(100); - PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); - PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); - - WorkingMemory wm = new DummyWorkingMemory(); - SoRequest soRequest = new SoRequest(); soRequest.setOperationType(SoOperationType.DELETE_VF_MODULE); - PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); - Future<SoResponse> asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, + Future<SoResponse> asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); try { SoResponse response = asyncRestCallFuture.get(); @@ -305,8 +293,10 @@ public class SoManagerTest { fail("test should not throw an exception"); } - PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + manager = new SoManager(BASE_SO_URI, "sean", "citizen"); + manager.setRestGetTimeout(100); + + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); try { SoResponse response = asyncRestCallFuture.get(); @@ -324,7 +314,7 @@ public class SoManagerTest { request.getRequestStatus().setRequestState("ONGOING"); request.setOperationType(SoOperationType.DELETE_VF_MODULE); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -335,7 +325,7 @@ public class SoManagerTest { request.setRequestType("ReturnCompleted"); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -345,7 +335,7 @@ public class SoManagerTest { } request.setRequestType("ReturnFailed"); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -358,7 +348,7 @@ public class SoManagerTest { request.setRequestType("ReturnOnging200"); request.setRequestScope(new Integer(10).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -370,7 +360,7 @@ public class SoManagerTest { request.setRequestType("ReturnOnging202"); request.setRequestScope(new Integer(20).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -383,7 +373,7 @@ public class SoManagerTest { // Test timeout after 20 attempts for a response request.setRequestType("ReturnOnging202"); request.setRequestScope(new Integer(21).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -395,7 +385,7 @@ public class SoManagerTest { // Test bad response after 3 attempts for a response request.setRequestType("ReturnBadAfterWait"); request.setRequestScope(new Integer(3).toString()); - asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + asyncRestCallFuture = manager.asyncSoRestCall(UUID.randomUUID().toString(), this, UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); try { SoResponse response = asyncRestCallFuture.get(); @@ -404,4 +394,11 @@ public class SoManagerTest { fail("test should not throw an exception"); } } + + @Override + public void onSoResponseWrapper(SoResponseWrapper wrapper) { + // + // Nothing really needed to do + // + } } |