import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.lang3.tuple.Pair;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.onap.aai.domain.yang.ServiceInstance;
import org.onap.aai.domain.yang.Tenant;
import org.onap.policy.aai.AaiCqResponse;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
super(DEFAULT_ACTOR, VfModuleDelete.NAME);
}
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ initBeforeClass();
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() {
+ destroyAfterClass();
+ }
/**
* Sets up.
oper = new MyOperation(params, config);
}
+ /**
+ * Tests "success" case with simulator.
+ */
+ @Test
+ public void testSuccess() throws Exception {
+ SoParams opParams = SoParams.builder().clientName(MY_CLIENT).path("serviceInstances/v7")
+ .pathGet("orchestrationRequests/v5/").maxGets(2).build();
+ config = new SoConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
+
+ params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
+ oper = new VfModuleDelete(params, config);
+
+ outcome = oper.start().get();
+ assertEquals(PolicyResult.SUCCESS, outcome.getResult());
+ }
+
@Test
public void testConstructor() {
assertEquals(DEFAULT_ACTOR, oper.getActorName());
Map<String, Object> payload = captor.getValue().getPayload();
assertNotNull(payload);
- @SuppressWarnings("unchecked")
- Map<String, Object> resource = (Map<String, Object>) payload.get("resource");
- assertNotNull(resource);
-
- @SuppressWarnings("unchecked")
- Map<String, Object> guard = (Map<String, Object>) resource.get("guard");
- assertNotNull(guard);
-
- Integer newCount = (Integer) guard.get(VfModuleDelete.PAYLOAD_KEY_VF_COUNT);
+ Integer newCount = (Integer) payload.get(VfModuleDelete.PAYLOAD_KEY_VF_COUNT);
assertNotNull(newCount);
assertEquals(origCount - 1, newCount.intValue());
}