summaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle
diff options
context:
space:
mode:
Diffstat (limited to 'appc-provider/appc-provider-bundle')
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java62
1 files changed, 34 insertions, 28 deletions
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java
index eaa8c3216..9c74dc877 100644
--- a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java
@@ -131,33 +131,23 @@ import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.Co
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeaderBuilder;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.Status;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.status.StatusBuilder;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.onap.appc.domainmodel.lcm.ResponseContext;
import org.onap.appc.executor.objects.LCMCommandStatus;
import org.onap.appc.provider.lcm.service.*;
import org.onap.appc.provider.lcm.util.ValidationService;
import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
-import org.osgi.framework.FrameworkUtil;
import org.onap.appc.provider.Whitebox;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
-/*
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-import org.powermock.reflect.Whitebox;
-*/
-
-import java.time.Clock;
-import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
+import java.util.TimeZone;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -166,19 +156,12 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-/*
-import static org.powermock.api.mockito.PowerMockito.mockStatic;
-import static org.powermock.api.mockito.PowerMockito.whenNew;
-*/
/**
* Integration Test class for AppcProviderLcm.
*/
@SuppressWarnings("deprecation")
@RunWith(MockitoJUnitRunner.class)
-// @PrepareForTest({FrameworkUtil.class, AppcProviderLcm.class, QueryService.class, VolumeService.class,
-// QuiesceTrafficService.class, ValidationService.class})
-
public class AppcProviderLcmTest extends AbstractDataBrokerTest {
private Status successStatus = new StatusBuilder().setCode(400).setMessage("success").build();
private Status failStatus = new StatusBuilder().setCode(302)
@@ -225,6 +208,13 @@ public class AppcProviderLcmTest extends AbstractDataBrokerTest {
doReturn("success").when(successlcmStatus).getMessage();
}
+ @After
+ public void tearDown() throws Exception {
+ if (appcProviderLcm != null) {
+ appcProviderLcm.close();
+ }
+ }
+
@Test
public void testConstructor() throws Exception {
Object executorService = Whitebox.getInternalState(appcProviderLcm, "executor");
@@ -1387,13 +1377,24 @@ public class AppcProviderLcmTest extends AbstractDataBrokerTest {
//Assert.assertEquals("Should return mockOutput", mockOutput, results.get().getResult());
}
- @After
- public void tearDown() throws Exception {
- if (appcProviderLcm != null) {
- appcProviderLcm.close();
- }
- }
+ @Test
+ public void testTimestampFormatShort() throws Exception {
+ // Validation success
+ doReturn("Success").when(successlcmStatus).getMessage();
+ doReturn(responseContext).when(requestHandlerOutput).getResponseContext();
+ doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any());
+ doReturn(null).when(validationService).validateInput(any(), any(), any());
+ ConfigExportInput configExportInput = mock(ConfigExportInput.class);
+ long epochWithZeroFractionalSeconds = 1529495219000l;
+ doReturn(newCommonHeader("request-id-aduit", epochWithZeroFractionalSeconds)).when(configExportInput).getCommonHeader();
+ doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id"))
+ .when(configExportInput).getActionIdentifiers();
+
+ Future<RpcResult<ConfigExportOutput>> results = appcProviderLcm.configExport
+ (configExportInput);
+ Assert.assertEquals(302, (int)results.get().getResult().getStatus().getCode());
+ }
private ActionIdentifiers newActionIdentifier(String vnfId, String vnfcId, String vserverId) {
ActionIdentifiersBuilder actionIdentifiersBuilder = new ActionIdentifiersBuilder();
@@ -1404,12 +1405,17 @@ public class AppcProviderLcmTest extends AbstractDataBrokerTest {
}
private CommonHeader newCommonHeader(String requestId) {
+ return newCommonHeader(requestId, System.currentTimeMillis());
+ }
+
+ private CommonHeader newCommonHeader(String requestId, long epoch) {
CommonHeaderBuilder commonHeaderBuilder = new CommonHeaderBuilder();
commonHeaderBuilder.setRequestId(requestId);
commonHeaderBuilder.setApiVer("2.0.0");
commonHeaderBuilder.setOriginatorId("originatortest");
- commonHeaderBuilder.setTimestamp(ZULU.getDefaultInstance(LocalDateTime.now(Clock.systemUTC()).toString() +
- "Z"));
+ DateFormat ZULU_FORMATTER = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SS'Z'");
+ ZULU_FORMATTER.setTimeZone(TimeZone.getTimeZone("UTC"));
+ commonHeaderBuilder.setTimestamp(ZULU.getDefaultInstance(ZULU_FORMATTER.format(epoch)));
return commonHeaderBuilder.build();
}
}