private static final Logger logger = LoggerFactory.getLogger(AppcServiceProviderTest.class);
- private static VirtualControlLoopEvent onsetEvent;
- private static ControlLoopOperation operation;
- private static Policy policy;
+ private static final VirtualControlLoopEvent onsetEvent;
+ private static final ControlLoopOperation operation;
+ private static final Policy policy;
static {
/*
@Test
public void constructModifyConfigRequestTest() {
- Request appcRequest = null;
+ Request appcRequest;
appcRequest = APPCActorServiceProvider.constructRequest(onsetEvent, operation, policy, "vnf01");
/* The service provider must return a non null APPC request */
return new AbstractMap.SimpleEntry<>(PolicyResult.FAILURE_EXCEPTION, message);
}
- /* Save the APPC response's message for Policy noticiation message. */
+ /* Save the APPC response's message for Policy notification message. */
message = appcResponse.getStatus().getMessage();
/* Maps the APPC response result to a Policy result. */
* This method reads and validates environmental properties coming from the policy engine. Null
* properties cause an {@link IllegalArgumentException} runtime exception to be thrown
*
- * @param string the name of the parameter to retrieve
+ * @param enginePropertyName the name of the parameter to retrieve
* @return the property value
*/
private static String getPeManagerEnvProperty(String enginePropertyName) {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import java.time.Instant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
public class AppcLcmServiceProviderTest {
private static final Logger logger = LoggerFactory.getLogger(AppcLcmServiceProviderTest.class);
- private static VirtualControlLoopEvent onsetEvent;
- private static ControlLoopOperation operation;
- private static Policy policy;
- private static LcmRequestWrapper dmaapRequest;
- private static LcmResponseWrapper dmaapResponse;
+ private static final VirtualControlLoopEvent onsetEvent;
+ private static final ControlLoopOperation operation;
+ private static final Policy policy;
+ private static final LcmResponseWrapper dmaapResponse;
static {
/*
policy.setTimeout(300);
/* A sample DMAAP request wrapper. */
- dmaapRequest = new LcmRequestWrapper();
+ LcmRequestWrapper dmaapRequest = new LcmRequestWrapper();
dmaapRequest.setCorrelationId(onsetEvent.getRequestId().toString() + "-" + "1");
dmaapRequest.setRpcName(policy.getRecipe().toLowerCase());
dmaapRequest.setType("request");
dmaapResponse.getBody().getStatus().setCode(100);
dmaapResponse.getBody().getStatus().setMessage("ACCEPTED");
result = AppcLcmActorServiceProvider.processResponse(dmaapResponse);
- assertEquals(null, result.getKey());
+ assertNull(result.getKey());
/* If APPC is successful, PolicyResult is success */
dmaapResponse.getBody().getStatus().setCode(400);
// Perform named query request and handle response
AaiNqResponseWrapper aaiResponseWrapper = performAaiNamedQueryRequest(onset);
if (aaiResponseWrapper == null) {
- // Tracing and error handling handied in the "performAaiNamedQueryRequest()" method
+ // Tracing and error handling handled in the "performAaiNamedQueryRequest()" method
return null;
}
/**
* Constructs and sends an AAI vserver Named Query.
*
- * @param onset the virtial control loop event
- * @returns the response to the AAI Named Query
+ * @param onset the virtual control loop event
+ * @return the response to the AAI Named Query
*/
private AaiNqResponseWrapper performAaiNamedQueryRequest(VirtualControlLoopEvent onset) {
* @return the base or non base index or -1 if the index was not found
*/
private int findIndex(List<AaiNqInventoryResponseItem> inventoryResponseItems, boolean baseIndexFlag) {
- for (AaiNqInventoryResponseItem invenoryResponseItem : inventoryResponseItems) {
- if (invenoryResponseItem.getVfModule() != null
- && baseIndexFlag == invenoryResponseItem.getVfModule().getIsBaseVfModule()) {
- return inventoryResponseItems.indexOf(invenoryResponseItem);
+ for (AaiNqInventoryResponseItem inventoryResponseItem : inventoryResponseItems) {
+ if (inventoryResponseItem.getVfModule() != null
+ && baseIndexFlag == inventoryResponseItem.getVfModule().getIsBaseVfModule()) {
+ return inventoryResponseItems.indexOf(inventoryResponseItem);
}
}
@SuppressWarnings("unused")
private int findNonBaseModules(List<AaiNqInventoryResponseItem> inventoryResponseItems) {
int nonBaseModuleCount = 0;
- for (AaiNqInventoryResponseItem invenoryResponseItem : inventoryResponseItems) {
- if (invenoryResponseItem.getVfModule() != null
- && (!invenoryResponseItem.getVfModule().getIsBaseVfModule())) {
+ for (AaiNqInventoryResponseItem inventoryResponseItem : inventoryResponseItems) {
+ if (inventoryResponseItem.getVfModule() != null
+ && (!inventoryResponseItem.getVfModule().getIsBaseVfModule())) {
nonBaseModuleCount++;
}
}
* This method reads and validates environmental properties coming from the policy engine. Null
* properties cause an {@link IllegalArgumentException} runtime exception to be thrown
*
- * @param string the name of the parameter to retrieve
+ * @param enginePropertyName the name of the parameter to retrieve
* @return the property value
*/
private static String getPeManagerEnvProperty(String enginePropertyName) {
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
+import java.util.Objects;
import java.util.UUID;
import org.junit.AfterClass;
VFCRequest request =
VFCActorServiceProvider.constructRequest(onset, operation, policy, new AaiGetVnfResponse());
- assertEquals(requestId, request.getRequestId());
+ assertEquals(requestId, Objects.requireNonNull(request).getRequestId());
assertEquals("dorothy.gale.1939", request.getHealRequest().getVnfInstanceId());
assertEquals("restartvm", request.getHealRequest().getAdditionalParams().getAction());
}
private static ActorService service;
// USed to load actors
- private ServiceLoader<Actor> loader;
+ private final ServiceLoader<Actor> loader;
private ActorService() {
loader = ServiceLoader.load(Actor.class);
public interface Actor {
- public String actor();
+ String actor();
- public List<String> recipes();
+ List<String> recipes();
- public List<String> recipeTargets(String recipe);
+ List<String> recipeTargets(String recipe);
- public List<String> recipePayloads(String recipe);
+ List<String> recipePayloads(String recipe);
}
@Override
public List<String> recipes() {
- List<String> recipieList = new ArrayList<>();
- recipieList.add("Dorothy");
- recipieList.add("Wizard");
+ List<String> recipeList = new ArrayList<>();
+ recipeList.add("Dorothy");
+ recipeList.add("Wizard");
- return recipieList;
+ return recipeList;
}
@Override
public List<String> recipeTargets(String recipe) {
- List<String> recipieTargetList = new ArrayList<>();
- recipieTargetList.add("Wicked Witch");
- recipieTargetList.add("Wizard of Oz");
+ List<String> recipeTargetList = new ArrayList<>();
+ recipeTargetList.add("Wicked Witch");
+ recipeTargetList.add("Wizard of Oz");
- return recipieTargetList;
+ return recipeTargetList;
}
@Override
public List<String> recipePayloads(String recipe) {
- List<String> recipiePayloadList = new ArrayList<>();
- recipiePayloadList.add("Dorothy");
- recipiePayloadList.add("Toto");
+ List<String> recipePayloadList = new ArrayList<>();
+ recipePayloadList.add("Dorothy");
+ recipePayloadList.add("Toto");
- return recipiePayloadList;
+ return recipePayloadList;
}
}