From afe5abed95c6cbfe239066e267d9c10a71f20623 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 15 May 2020 09:52:35 -0400 Subject: Cannot parse finishTime in SO responses The timestamp in SO responses appears to follow RFC-1123/RFC-822 format instead of ISO format. Added a type adapter for SO. In Guilin, we may want to consider combining the two type adapters for LocalDateTime so that either format is accepted. Also modified the SO simulator to return responses that are actual samples from SO. As part of that work, discovered that the legacy SO actor is not able to parse these timestamps either. However, as that code is now deprecated, left it as is. Issue-ID: POLICY-2570 Change-Id: I322318d1007e36eef47bb8867fd8ed01cb60223a Signed-off-by: Jim Hahn --- .../policy/controlloop/actor/so/BasicSoOperation.java | 4 ++-- .../policy/controlloop/actor/so/SoOperationTest.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'models-interactions/model-actors/actor.so/src/test') diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java index 0232226e0..aaecb46a8 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/BasicSoOperation.java @@ -96,11 +96,11 @@ public abstract class BasicSoOperation extends BasicHttpOperation { .serializationProvider(GsonMessageBodyHandler.class.getName()).build(); HttpClientFactoryInstance.getClientFactory().build(clientParams); - SoSimulatorJaxRs.setYieldIncomplete(true); + SoSimulatorJaxRs.setRequirePolling(true); } protected static void destroyAfterClass() { - SoSimulatorJaxRs.setYieldIncomplete(false); + SoSimulatorJaxRs.setRequirePolling(false); HttpClientFactoryInstance.getClientFactory().destroy(); HttpServletServerFactoryInstance.getServerFactory().destroy(); } diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java index 70093967c..644521869 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java @@ -32,6 +32,8 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.time.LocalDateTime; +import java.time.Month; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -46,6 +48,7 @@ import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.Tenant; import org.onap.policy.aai.AaiCqResponse; +import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; @@ -422,4 +425,18 @@ public class SoOperationTest extends BasicSoOperation { when(cq.getDefaultCloudRegion()).thenReturn(region); assertSame(region, oper.getDefaultCloudRegion(cq)); } + + @Test + public void testMakeCoder() throws CoderException { + Coder opcoder = oper.makeCoder(); + + // ensure we can decode an SO timestamp + String json = "{'request':{'finishTime':'Fri, 15 May 2020 12:14:21 GMT'}}"; + SoResponse resp = opcoder.decode(json.replace('\'', '"'), SoResponse.class); + + LocalDateTime tfinish = resp.getRequest().getFinishTime(); + assertNotNull(tfinish); + assertEquals(2020, tfinish.getYear()); + assertEquals(Month.MAY, tfinish.getMonth()); + } } -- cgit 1.2.3-korg