summaryrefslogtreecommitdiffstats
path: root/nokiav2/generatedapis/src/test/java/TestInhertence.java
diff options
context:
space:
mode:
Diffstat (limited to 'nokiav2/generatedapis/src/test/java/TestInhertence.java')
-rw-r--r--nokiav2/generatedapis/src/test/java/TestInhertence.java43
1 files changed, 42 insertions, 1 deletions
diff --git a/nokiav2/generatedapis/src/test/java/TestInhertence.java b/nokiav2/generatedapis/src/test/java/TestInhertence.java
index f7e1108a..63e185e1 100644
--- a/nokiav2/generatedapis/src/test/java/TestInhertence.java
+++ b/nokiav2/generatedapis/src/test/java/TestInhertence.java
@@ -16,6 +16,7 @@
import com.nokia.cbam.lcm.v32.ApiClient;
import com.nokia.cbam.lcm.v32.model.*;
+import com.nokia.cbam.lcm.v32.JSON;
import okhttp3.Headers;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
@@ -24,11 +25,15 @@ import okio.Buffer;
import okio.BufferedSource;
import org.junit.Test;
+import org.threeten.bp.OffsetDateTime;
+import org.threeten.bp.ZoneOffset;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.annotation.Annotation;
import static junit.framework.TestCase.assertEquals;
+import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
public class TestInhertence {
@@ -37,7 +42,7 @@ public class TestInhertence {
* test OpenStack v2 inheritence handling in serialization and deserialization
*/
@Test
- public void testOpenStackV2() throws IOException{
+ public void testInheritence() throws IOException{
InstantiateVnfRequest req = new InstantiateVnfRequest();
OPENSTACKV2INFO vim = new OPENSTACKV2INFO();
req.getVims().add(vim);
@@ -55,6 +60,42 @@ public class TestInhertence {
assertEquals("myPassword", deserializedVim.getAccessInfo().getPassword());
}
+ /**
+ * Test how dates are handled
+ */
+ @Test
+ public void testDateHandling() throws Exception{
+ VnfLifecycleChangeNotification vnfLifecycleChangeNotification = new VnfLifecycleChangeNotification();
+ OffsetDateTime fixedTime = OffsetDateTime.of(1981, 7, 4, 1,2,3,4, ZoneOffset.ofHours(0));
+ vnfLifecycleChangeNotification.setTimestamp(fixedTime);
+ vnfLifecycleChangeNotification.setNotificationType(VnfNotificationType.VNFLIFECYCLECHANGENOTIFICATION);
+ vnfLifecycleChangeNotification.setVnfInstanceId("vnfId");
+ Annotation[] x = new Annotation[0];
+ RequestBody requestBody = new ApiClient().getAdapterBuilder().build().requestBodyConverter(VnfLifecycleChangeNotification.class, x, new Annotation[0]).convert(vnfLifecycleChangeNotification);
+ String content = getContent(requestBody);
+ assertTrue(content.contains("1981-07-04T01:02:03"));
+ ResponseBody responseBody = toResponse(requestBody);
+ VnfLifecycleChangeNotification deserialize = (VnfLifecycleChangeNotification) new ApiClient().getAdapterBuilder().build().responseBodyConverter(VnfLifecycleChangeNotification.class, new Annotation[0]).convert(responseBody);
+ assertEquals(fixedTime, deserialize.getTimestamp());
+ }
+
+ @Test
+ public void testRawDateHAndling()throws Exception{
+ String content= "{\n" +
+ "\t\"status\": \"STARTED\",\n" +
+ "\t\"vnfInstanceId\": \"CBAM-3f081d70e0da4a44bd8d7b52e4dddbeb\",\n" +
+ "\t\"timestamp\": \"2018-03-24T07:11:09.910335Z\",\n" +
+ "\t\"notificationType\": \"VnfLifecycleChangeNotification\",\n" +
+ "\t\"lifecycleOperationOccurrenceId\": \"CBAM-158182e3df6744109cd980d52f608698\",\n" +
+ "\t\"subscriptionId\": \"CBAM-190e87ba3c0d4348a8d5b0c21bccc11d\",\n" +
+ "\t\"operation\": \"TERMINATE\"\n" +
+ "}";
+
+
+ VnfLifecycleChangeNotification deserialized = new JSON().getGson().fromJson(content, VnfLifecycleChangeNotification.class);
+ assertNotNull(deserialized.getTimestamp());
+ }
+
private ResponseBody toResponse(RequestBody convert) throws IOException {
Headers headers = new Headers.Builder().build();
Buffer buffer = new Buffer();