aboutsummaryrefslogtreecommitdiffstats
path: root/appc-config/appc-flow-controller/provider/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'appc-config/appc-flow-controller/provider/src/test/java')
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InputParamsCollectorTest.java6
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InventoryInfoExtractorTest.java58
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java28
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java15
-rw-r--r--appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java23
5 files changed, 79 insertions, 51 deletions
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InputParamsCollectorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InputParamsCollectorTest.java
index dbf821e99..951c38dc5 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InputParamsCollectorTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InputParamsCollectorTest.java
@@ -3,6 +3,7 @@
* ONAP : APPC
* ================================================================================
* Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -80,8 +81,7 @@ public class InputParamsCollectorTest {
Transaction transaction = inputParamsCollector.collectInputParams(ctx);
- Assert.assertEquals(
- "{\"input\":{\"request-info\":{\"action\":\"some-request-action\",\"payload\":\"some-payload\",\"action-level\":\"some-action-level\",\"action-identifier\":{\"vnf-id\":\"some-vnf-id\",\"vserver-id\":\"some-vserver-id\",\"vnfc-name\":\"some-vnfc-name\"}},\"inventory-info\":{\"vnf-info\":{\"vnf-id\":\"some-vnf-id\",\"vm\":[]}},\"dependency-info\":{\"vnfcs\":[{\"vnfc-type\":\"some-type\",\"mandatory\":\"some-mandatory\",\"resilience\":\"some-resilience\",\"parents\":[]},{\"vnfc-type\":\"some-type\",\"mandatory\":\"some-mandatory\",\"resilience\":\"some-resilience\",\"parents\":[]}]},\"capabilities\":{\"vnf\":[\"vnf-1\",\"vnf-2\"],\"vm\":[\"vm-1\",\"vm-2\"],\"vnfc\":[\"vnfc-1\",\"vnfc-2\"],\"vf-module\":[\"vf-module-1\",\"vf-module-2\"]}}}",
+ Assert.assertEquals("{\"input\":{\"request-info\":{\"action\":\"some-request-action\",\"payload\":\"some-payload\",\"action-level\":\"some-action-level\",\"action-identifier\":{\"vnf-id\":\"some-vnf-id\",\"vserver-id\":\"some-vserver-id\",\"vnfc-name\":\"some-vnfc-name\"}},\"inventory-info\":{\"vnf-info\":{\"vnf-id\":\"some-vnf-id\",\"identity-url\":\"\",\"vm\":[]}},\"capabilities\":{\"vnf\":[\"vnf-1\",\"vnf-2\"],\"vm\":[\"vm-1\",\"vm-2\"],\"vnfc\":[\"vnfc-1\",\"vnfc-2\"],\"vf-module\":[\"vf-module-1\",\"vf-module-2\"]}}}",
transaction.getPayload());
Assert.assertEquals("POST", transaction.getExecutionRPC());
Assert.assertEquals("seq-generator-uid", transaction.getuId());
@@ -127,4 +127,4 @@ public class InputParamsCollectorTest {
return new ObjectMapper().writeValueAsString(input);
}
-} \ No newline at end of file
+}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InventoryInfoExtractorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InventoryInfoExtractorTest.java
index 66484da1e..314c0ed05 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InventoryInfoExtractorTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/InventoryInfoExtractorTest.java
@@ -3,6 +3,7 @@
* ONAP : APPC
* ================================================================================
* Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +27,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onap.appc.flow.controller.interfaceData.InventoryInfo;
+import org.onap.appc.flow.controller.interfaceData.VnfInfo;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class InventoryInfoExtractorTest {
@@ -55,11 +57,15 @@ public class InventoryInfoExtractorTest {
when(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-name")).thenReturn("some-vnfc-name-1");
when(ctx.getAttribute("tmp.vnfInfo.vm[1].vnfc-type")).thenReturn("some-vnfc-type-1");
+ when(ctx.getAttribute("tmp.vnfInfo.identity-url")).thenReturn("some-url");
+
String vnfId = "some-vnf-id";
InventoryInfo inventoryInfo = inventoryInfoExtractor.getInventoryInfo(ctx, vnfId);
Assert.assertEquals(
- "InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, vnfType=some-vnf-type, vm=[Vm [vserverId=some-id-0, vnfc=Vnfcslist [vnfcType=some-vnfc-type-0, vnfcName=some-vnfc-name-0]], Vm [vserverId=some-id-1, vnfc=Vnfcslist [vnfcType=some-vnfc-type-1, vnfcName=some-vnfc-name-1]]]]]",
+ "InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, vnfType=some-vnf-type, " +
+ "identityUrl=some-url, vm=[Vm [vserverId=some-id-0, vmId=null, " +
+ "vnfc=Vnfcslist [vnfcType=some-vnfc-type-0, vnfcName=some-vnfc-name-0]], Vm [vserverId=some-id-1, vmId=null, vnfc=Vnfcslist [vnfcType=some-vnfc-type-1, vnfcName=some-vnfc-name-1]]]]]",
inventoryInfo.toString());
}
@@ -68,6 +74,7 @@ public class InventoryInfoExtractorTest {
when(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-name")).thenReturn("some-vnf-name");
when(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-type")).thenReturn("some-vnf-type");
when(ctx.getAttribute("tmp.vnfInfo.vm-count")).thenReturn("2");
+ when(ctx.getAttribute("tmp.vnfInfo.identity-url")).thenReturn("some-url");
when(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id")).thenReturn("some-id-0");
when(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-count")).thenReturn("2");
@@ -83,8 +90,11 @@ public class InventoryInfoExtractorTest {
InventoryInfo inventoryInfo = inventoryInfoExtractor.getInventoryInfo(ctx, vnfId);
Assert.assertEquals(
- "InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, vnfType=some-vnf-type, vm=[Vm [vserverId=some-id-0, vnfc=Vnfcslist [vnfcType=some-vnfc-type-0, vnfcName=some-vnfc-name-0]], Vm [vserverId=some-id-1, vnfc=null]]]]",
- inventoryInfo.toString());
+ "InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, "
+ + "vnfType=some-vnf-type, identityUrl=some-url, vm=[Vm [vserverId=some-id-0, "
+ + "vmId=null, vnfc=Vnfcslist [vnfcType=some-vnfc-type-0, vnfcName=some-vnfc-name-0]], "
+ + "Vm [vserverId=some-id-1, vmId=null, vnfc=null]]]]",
+ inventoryInfo.toString());
}
@Test
@@ -92,6 +102,8 @@ public class InventoryInfoExtractorTest {
when(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-name")).thenReturn("some-vnf-name");
when(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-type")).thenReturn("some-vnf-type");
when(ctx.getAttribute("tmp.vnfInfo.vm-count")).thenReturn("0");
+ when(ctx.getAttribute("tmp.vnfInfo.identity-url")).thenReturn("some-url");
+
when(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id")).thenReturn("some-id-0");
when(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-count")).thenReturn("2");
@@ -106,9 +118,9 @@ public class InventoryInfoExtractorTest {
String vnfId = "some-vnf-id";
InventoryInfo inventoryInfo = inventoryInfoExtractor.getInventoryInfo(ctx, vnfId);
- Assert.assertEquals(
- "InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, vnfType=some-vnf-type, vm=null]]",
- inventoryInfo.toString());
+ Assert.assertEquals("InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, "
+ + "vnfType=some-vnf-type, identityUrl=some-url, vm=null]]",
+ inventoryInfo.toString());
}
@Test
@@ -116,6 +128,7 @@ public class InventoryInfoExtractorTest {
when(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-name")).thenReturn("some-vnf-name");
when(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-type")).thenReturn("some-vnf-type");
when(ctx.getAttribute("tmp.vnfInfo.vm-count")).thenReturn("");
+ when(ctx.getAttribute("tmp.vnfInfo.identity-url")).thenReturn("some-url");
when(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id")).thenReturn("some-id-0");
when(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-count")).thenReturn("2");
@@ -131,8 +144,9 @@ public class InventoryInfoExtractorTest {
InventoryInfo inventoryInfo = inventoryInfoExtractor.getInventoryInfo(ctx, vnfId);
Assert.assertEquals(
- "InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, vnfType=some-vnf-type, vm=null]]",
- inventoryInfo.toString());
+ "InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, "
+ + "vnfType=some-vnf-type, identityUrl=some-url, vm=null]]",
+ inventoryInfo.toString());
}
@Test
@@ -140,6 +154,7 @@ public class InventoryInfoExtractorTest {
when(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-name")).thenReturn("some-vnf-name");
when(ctx.getAttribute("tmp.vnfInfo.vnf.vnf-type")).thenReturn("some-vnf-type");
when(ctx.getAttribute("tmp.vnfInfo.vm-count")).thenReturn(null);
+ when(ctx.getAttribute("tmp.vnfInfo.identity-url")).thenReturn("some-url");
when(ctx.getAttribute("tmp.vnfInfo.vm[0].vserver-id")).thenReturn("some-id-0");
when(ctx.getAttribute("tmp.vnfInfo.vm[0].vnfc-count")).thenReturn("2");
@@ -155,8 +170,29 @@ public class InventoryInfoExtractorTest {
InventoryInfo inventoryInfo = inventoryInfoExtractor.getInventoryInfo(ctx, vnfId);
Assert.assertEquals(
- "InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, vnfType=some-vnf-type, vm=null]]",
- inventoryInfo.toString());
+ "InventoryInfo [vnfInfo=VnfInfo [vnfId=some-vnf-id, vnfName=some-vnf-name, "
+ + "vnfType=some-vnf-type, identityUrl=some-url, vm=null]]",
+ inventoryInfo.toString());
+ }
+
+ @Test
+ public void testGetIdentityUrl_from_payload() throws Exception{
+ InventoryInfoExtractor info = new InventoryInfoExtractor();
+ when(ctx.getAttribute("AICIdentity")).thenReturn("some_url");
+ VnfInfo vnfInfo = new VnfInfo();
+ String url=info.getIdentityUrl(ctx, vnfInfo, "123");
+ System.out.println(info.toString());
+ Assert.assertEquals(url, "some_url");
+ }
+
+ @Test
+ public void testGetIdentityUrl_from_Inventory() throws Exception{
+ InventoryInfoExtractor info = new InventoryInfoExtractor();
+ when(ctx.getAttribute("tmp.vnfInfo.identity-url")).thenReturn("some_url_from_inventory");
+ VnfInfo vnfInfo = new VnfInfo();
+ String url=info.getIdentityUrl(ctx, vnfInfo, "123");
+ System.out.println(info.toString());
+ Assert.assertEquals(url, "some_url_from_inventory");
}
-} \ No newline at end of file
+}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java
index 34227587a..67a4e36e0 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/ResourceUriExtractorTest.java
@@ -62,7 +62,7 @@ public class ResourceUriExtractorTest {
when(ctx.getAttribute(INPUT_URL)).thenReturn("http://localhost:8080");
resourceUriExtractor = new ResourceUriExtractor();
- String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx);
Assert.assertEquals("http://localhost:8080", resourceUri);
}
@@ -71,15 +71,13 @@ public class ResourceUriExtractorTest {
public void should_extract_url_input_if_context_input_provided() throws Exception {
when(ctx.getAttribute(INPUT_URL)).thenReturn("");
when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
- when(prop.getProperty(ctx.getAttribute(VNF_TYPE) + "." + (REST_PROTOCOL) + "."
- + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + (REST_PORT))).thenReturn("8080");
+ when(ctx.getAttribute(REST_PORT)).thenReturn("8080");
when(ctx.getAttribute(INPUT_CONTEXT)).thenReturn("input-context");
- when(ctx.getAttribute(INPUT_SUB_CONTEXT)).thenReturn("input-sub-context");
- String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx);
- Assert.assertEquals("http://localhost:8080/input-context/input-sub-context", resourceUri);
+ Assert.assertEquals("http://localhost:8080/input-context", resourceUri);
}
@Test
@@ -87,29 +85,27 @@ public class ResourceUriExtractorTest {
when(ctx.getAttribute(INPUT_REQUEST_ACTION)).thenReturn("request-action");
when(ctx.getAttribute(INPUT_URL)).thenReturn("");
when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
- when(prop.getProperty(ctx.getAttribute(VNF_TYPE) + "." + (REST_PROTOCOL) + "."
- + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + (REST_PORT))).thenReturn("8080");
-
- when(prop.getProperty(ctx.getAttribute(VNF_TYPE) + "." + REST_PROTOCOL + "."
- + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + REST_CONTEXT_URL)).thenReturn("ra-context");
+ when(ctx.getAttribute(REST_PORT)).thenReturn("8080");
+ when(ctx.getAttribute(INPUT_CONTEXT)).thenReturn("ra-context");
when(prop.getProperty("request-action.sub-context")).thenReturn("ra-sub-context");
- String resourceUri = resourceUriExtractor.extractResourceUri(ctx, prop);
+ String resourceUri = resourceUriExtractor.extractResourceUri(ctx);
- Assert.assertEquals("http://localhost:8080/ra-context/ra-sub-context", resourceUri);
+ Assert.assertEquals("http://localhost:8080/ra-context", resourceUri);
}
@Test
public void should_throw_exception_if_missing_context() throws Exception {
when(ctx.getAttribute(INPUT_URL)).thenReturn("");
when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
- when(prop.getProperty(ctx.getAttribute(VNF_TYPE) + "." + (REST_PROTOCOL) + "."
- + ctx.getAttribute(INPUT_REQUEST_ACTION) + "." + (REST_PORT))).thenReturn("8080");
+ when(ctx.getAttribute(INPUT_HOST_IP_ADDRESS)).thenReturn("localhost");
+ when(prop.getProperty(ctx.getAttribute(VNF_TYPE)+"."+(REST_PROTOCOL)+"."+ctx.getAttribute(INPUT_REQUEST_ACTION)
+ +"."+(REST_PORT))).thenReturn("8080");
expectedException.expect(Exception.class);
expectedException.expectMessage("Could not find the context for operation null");
- resourceUriExtractor.extractResourceUri(ctx, prop);
+ resourceUriExtractor.extractResourceUri(ctx);
}
}
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java
index 001581402..e49db45d4 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TestRestServiceNode.java
@@ -25,12 +25,10 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
-import static org.onap.appc.flow.controller.node.RestServiceNode.APPC_CONFIG_DIR_VAR;
import static org.onap.appc.flow.controller.node.RestServiceNode.REST_RESPONSE;
import static org.onap.appc.flow.controller.utils.FlowControllerConstants.INPUT_PARAM_RESPONSE_PREFIX;
import java.util.HashMap;
import java.util.Map;
-import java.util.Properties;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
@@ -75,14 +73,13 @@ public class TestRestServiceNode {
HashMap<String, String> restResponseMap = new HashMap<>();
restResponseMap.put(REST_RESPONSE, REST_BODY_RESPONSE.replaceAll("'", "\""));
- when(uriExtractorMock.extractResourceUri(any(SvcLogicContext.class), any(Properties.class)))
+ when(uriExtractorMock.extractResourceUri(any(SvcLogicContext.class)))
.thenReturn(RESOURCE_URI);
- when(transactionHandlerMock.buildTransaction(any(SvcLogicContext.class), any(Properties.class),
+ when(transactionHandlerMock.buildTransaction(any(SvcLogicContext.class),
eq(RESOURCE_URI))).thenReturn(transaction);
when(restExecutorMock.execute(eq(transaction), any(SvcLogicContext.class))).thenReturn(restResponseMap);
EnvVariables envVariables = mock(EnvVariables.class);
- when(envVariables.getenv(APPC_CONFIG_DIR_VAR)).thenReturn("src/test/resources");
restServiceNode = new RestServiceNode(transactionHandlerMock, restExecutorMock, uriExtractorMock, envVariables);
}
@@ -95,15 +92,15 @@ public class TestRestServiceNode {
restServiceNode.sendRequest(params, ctxMock);
// then
- verify(uriExtractorMock).extractResourceUri(eq(ctxMock), any(Properties.class));
- verify(transactionHandlerMock).buildTransaction(eq(ctxMock), any(Properties.class), eq(RESOURCE_URI));
+ verify(uriExtractorMock).extractResourceUri(eq(ctxMock));
+ verify(transactionHandlerMock).buildTransaction(eq(ctxMock), eq(RESOURCE_URI));
verify(restExecutorMock).execute(transaction, ctxMock);
verifyNoMoreInteractions(uriExtractorMock, transactionHandlerMock, restExecutorMock);
}
@Test
public void should_rethrow_exception_from_uri_extractor() throws Exception {
- when(uriExtractorMock.extractResourceUri(eq(ctxMock), any(Properties.class)))
+ when(uriExtractorMock.extractResourceUri(eq(ctxMock)))
.thenThrow(new Exception("resource uri exception"));
expectedException.expect(SvcLogicException.class);
@@ -114,7 +111,7 @@ public class TestRestServiceNode {
@Test
public void should_rethrow_exception_from_transaction_handler() throws Exception {
- when(transactionHandlerMock.buildTransaction(eq(ctxMock), any(Properties.class), eq(RESOURCE_URI)))
+ when(transactionHandlerMock.buildTransaction(eq(ctxMock), eq(RESOURCE_URI)))
.thenThrow(new Exception("transaction exception"));
expectedException.expect(SvcLogicException.class);
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java
index a57a8c043..007f33b6f 100644
--- a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java
+++ b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java
@@ -3,6 +3,7 @@
* ONAP : APPC
* ================================================================================
* Copyright (C) 2018 Nokia. All rights reserved.
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* =============================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,9 +60,9 @@ public class TransactionHandlerTest {
when(ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE)).thenReturn("");
expectedException.expect(Exception.class);
- expectedException.expectMessage("Don't know vnf type to send REST request for request-action - null");
+ expectedException.expectMessage("Don't know REST operation for Action");
transactionHandler = new TransactionHandler();
- transactionHandler.buildTransaction(ctx, prop, RESOURCE_URI);
+ transactionHandler.buildTransaction(ctx, RESOURCE_URI);
}
@Test
@@ -70,8 +71,8 @@ public class TransactionHandlerTest {
when(ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE)).thenReturn("foo");
expectedException.expect(Exception.class);
- expectedException.expectMessage("Don't know vnf type to send REST request for request-action - null");
- transactionHandler.buildTransaction(ctx, prop, "some uri");
+ expectedException.expectMessage("Don't know request-action request-action");
+ transactionHandler.buildTransaction(ctx, "some uri");
}
@Test
@@ -80,18 +81,16 @@ public class TransactionHandlerTest {
when(ctx.getAttribute(INPUT_REQUEST_ACTION_TYPE)).thenReturn("input-ra-type");
when(ctx.getAttribute(INPUT_REQUEST_ACTION)).thenReturn("input-ra");
when(ctx.getAttribute(VNF_TYPE)).thenReturn("vnf");
-
- String userKey = ctx.getAttribute(VNF_TYPE) + "." + REST_PROTOCOL + "." + ctx.getAttribute(INPUT_REQUEST_ACTION)
+
+ String userKey = ctx.getAttribute(VNF_TYPE) + "." + REST_PROTOCOL + "." + ctx.getAttribute(INPUT_REQUEST_ACTION)
+ ".user";
- String passwordKey = ctx.getAttribute(VNF_TYPE) + "." + REST_PROTOCOL + "." + ctx.getAttribute(INPUT_REQUEST_ACTION)
+ String passwordKey = ctx.getAttribute(VNF_TYPE) + "." + REST_PROTOCOL + "." + ctx.getAttribute(INPUT_REQUEST_ACTION)
+ ".password";
- when(prop.getProperty(userKey))
- .thenReturn("rest-user");
- when(prop.getProperty(passwordKey))
- .thenReturn("rest-pass");
+ when(ctx.getAttribute("user")).thenReturn("rest-user");
+ when(ctx.getAttribute("pwd")).thenReturn("rest-pass");
- Transaction transaction = transactionHandler.buildTransaction(ctx, prop, "some uri");
+ Transaction transaction = transactionHandler.buildTransaction(ctx,"some uri");
Assert.assertEquals(INPUT_REQUEST_ACTION, transaction.getAction());
Assert.assertEquals("input-ra-type", transaction.getExecutionRPC());