Upgrade and clean up dependencies
[policy/models.git] / models-interactions / model-actors / actor.so / src / test / java / org / onap / policy / controlloop / actor / so / VfModuleCreateTest.java
index 8dca7c8..ad242c0 100644 (file)
@@ -2,8 +2,9 @@
  * ============LICENSE_START=======================================================
  * ONAP
  * ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2020 Wipro Limited.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,6 +39,8 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.onap.aai.domain.yang.CloudRegion;
 import org.onap.aai.domain.yang.GenericVnf;
 import org.onap.aai.domain.yang.ModelVer;
@@ -53,6 +56,7 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingPa
 import org.onap.policy.so.SoRequest;
 import org.onap.policy.so.SoResponse;
 
+@RunWith(MockitoJUnitRunner.class)
 public class VfModuleCreateTest extends BasicSoOperation {
 
 
@@ -98,7 +102,7 @@ public class VfModuleCreateTest extends BasicSoOperation {
                         .maxPolls(2).build();
         config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory());
 
-        params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).preprocessed(true).build();
+        params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build();
 
         oper = new VfModuleCreate(params, config);
 
@@ -212,6 +216,20 @@ public class VfModuleCreateTest extends BasicSoOperation {
         verifyRequest("vfModuleCreate.json", pair.getRight());
     }
 
+    /**
+     * Tests makeRequest() when a property is missing.
+     */
+    @Test
+    public void testMakeRequestMissingProperty() throws Exception {
+        loadProperties();
+
+        ServiceInstance instance = new ServiceInstance();
+        oper.setProperty(OperationProperties.AAI_SERVICE, instance);
+
+        assertThatIllegalArgumentException().isThrownBy(() -> oper.makeRequest())
+                        .withMessageContaining("missing service instance ID");
+    }
+
     private void loadProperties() {
         // set the properties
         ServiceInstance instance = new ServiceInstance();
@@ -229,8 +247,13 @@ public class VfModuleCreateTest extends BasicSoOperation {
         vnf.setVnfId(VNF_ID);
         oper.setProperty(OperationProperties.AAI_VNF, vnf);
 
-        oper.setProperty(OperationProperties.AAI_DEFAULT_CLOUD_REGION, new CloudRegion());
-        oper.setProperty(OperationProperties.AAI_DEFAULT_TENANT, new Tenant());
+        CloudRegion cloudRegion = new CloudRegion();
+        cloudRegion.setCloudRegionId("my-cloud-id");
+        oper.setProperty(OperationProperties.AAI_DEFAULT_CLOUD_REGION, cloudRegion);
+
+        Tenant tenant = new Tenant();
+        tenant.setTenantId("my-tenant-id");
+        oper.setProperty(OperationProperties.AAI_DEFAULT_TENANT, tenant);
 
         oper.setProperty(OperationProperties.DATA_VF_COUNT, VF_COUNT);
     }