From b078c9d89a9d6c07f7cb6e7196b34caf797138d6 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Thu, 15 Nov 2018 11:59:54 +0900 Subject: Rename test classes in drools-applications Make test classes name consistence by putting 'Test' at end as per google java style guide Issue-ID: POLICY-1258 Change-Id: Id79e5d3fe3688f7f2569b7996613595cc6b746e7 Signed-off-by: Parshad Patel --- .../ActorServiceProviderTest.java | 53 +++ .../TestActorServiceProvider.java | 53 --- .../org/onap/policy/appc/CommonHeaderTest.java | 178 +++++++++ .../test/java/org/onap/policy/appc/EnumsTest.java | 74 ++++ .../java/org/onap/policy/appc/RequestTest.java | 124 +++++++ .../org/onap/policy/appc/ResponseStatusTest.java | 88 +++++ .../java/org/onap/policy/appc/ResponseTest.java | 104 ++++++ .../org/onap/policy/appc/TestCommonHeader.java | 178 --------- .../test/java/org/onap/policy/appc/TestEnums.java | 74 ---- .../java/org/onap/policy/appc/TestRequest.java | 124 ------- .../java/org/onap/policy/appc/TestResponse.java | 104 ------ .../org/onap/policy/appc/TestResponseStatus.java | 88 ----- .../onap/policy/appc/util/SerializationTest.java | 56 +++ .../onap/policy/appc/util/TestSerialization.java | 56 --- .../onap/policy/appclcm/LcmCommonHeaderTest.java | 143 ++++++++ .../org/onap/policy/appclcm/LcmRequestTest.java | 111 ++++++ .../onap/policy/appclcm/LcmRequestWrapperTest.java | 66 ++++ .../onap/policy/appclcm/LcmResonseCodeTest.java | 55 +++ .../onap/policy/appclcm/LcmResponseStatusTest.java | 74 ++++ .../policy/appclcm/LcmResponseWrapperTest.java | 65 ++++ .../org/onap/policy/appclcm/LcmWrapperTest.java | 115 ++++++ .../onap/policy/appclcm/TestLcmCommonHeader.java | 143 -------- .../org/onap/policy/appclcm/TestLcmRequest.java | 111 ------ .../onap/policy/appclcm/TestLcmRequestWrapper.java | 66 ---- .../onap/policy/appclcm/TestLcmResonseCode.java | 55 --- .../onap/policy/appclcm/TestLcmResponseStatus.java | 74 ---- .../policy/appclcm/TestLcmResponseWrapper.java | 65 ---- .../org/onap/policy/appclcm/TestLcmWrapper.java | 115 ------ .../policy/appclcm/util/SerializationTest.java | 57 +++ .../policy/appclcm/util/TestSerialization.java | 57 --- .../test/java/org/onap/policy/rest/GetTest.java | 66 ++++ .../test/java/org/onap/policy/rest/PairTest.java | 42 +++ .../test/java/org/onap/policy/rest/PostTest.java | 50 +++ .../test/java/org/onap/policy/rest/TestGet.java | 66 ---- .../test/java/org/onap/policy/rest/TestPair.java | 42 --- .../test/java/org/onap/policy/rest/TestPost.java | 50 --- .../org/onap/policy/sdc/ResourceInstanceTest.java | 155 ++++++++ .../java/org/onap/policy/sdc/ResourceTest.java | 152 ++++++++ .../org/onap/policy/sdc/ServiceInstanceTest.java | 170 +++++++++ .../test/java/org/onap/policy/sdc/ServiceTest.java | 137 +++++++ .../java/org/onap/policy/sdc/TestResource.java | 152 -------- .../org/onap/policy/sdc/TestResourceInstance.java | 155 -------- .../test/java/org/onap/policy/sdc/TestService.java | 137 ------- .../org/onap/policy/sdc/TestServiceInstance.java | 170 --------- .../test/java/org/onap/policy/sdnc/DemoTest.java | 71 ++++ .../policy/sdnc/SdncHealAdditionalParamsTest.java | 47 +++ .../org/onap/policy/sdnc/SdncHealRequestTest.java | 43 +++ .../onap/policy/sdnc/SdncHealServiceInfoTest.java | 43 +++ .../java/org/onap/policy/sdnc/SdncManagerTest.java | 281 ++++++++++++++ .../java/org/onap/policy/sdnc/SdncRequestTest.java | 53 +++ .../policy/sdnc/SdncResponseDescriptorTest.java | 54 +++ .../org/onap/policy/sdnc/SdncResponseTest.java | 48 +++ .../test/java/org/onap/policy/sdnc/TestDemo.java | 71 ---- .../policy/sdnc/TestSdncHealAdditionalParams.java | 47 --- .../org/onap/policy/sdnc/TestSdncHealRequest.java | 43 --- .../onap/policy/sdnc/TestSdncHealServiceInfo.java | 43 --- .../java/org/onap/policy/sdnc/TestSdncManager.java | 281 -------------- .../java/org/onap/policy/sdnc/TestSdncRequest.java | 53 --- .../org/onap/policy/sdnc/TestSdncResponse.java | 48 --- .../policy/sdnc/TestSdncResponseDescriptor.java | 54 --- .../onap/policy/sdnc/util/SerializationTest.java | 35 ++ .../onap/policy/sdnc/util/TestSerialization.java | 35 -- .../org/onap/policy/sdnr/PciCommonHeaderTest.java | 144 ++++++++ .../java/org/onap/policy/sdnr/PciRequestTest.java | 92 +++++ .../onap/policy/sdnr/PciRequestWrapperTest.java | 66 ++++ .../org/onap/policy/sdnr/PciResponseCodeTest.java | 55 +++ .../onap/policy/sdnr/PciResponseWrapperTest.java | 66 ++++ .../java/org/onap/policy/sdnr/PciStatusTest.java | 74 ++++ .../java/org/onap/policy/sdnr/PciWrapperTest.java | 115 ++++++ .../org/onap/policy/sdnr/TestPciCommonHeader.java | 144 -------- .../java/org/onap/policy/sdnr/TestPciRequest.java | 92 ----- .../onap/policy/sdnr/TestPciRequestWrapper.java | 66 ---- .../org/onap/policy/sdnr/TestPciResponseCode.java | 55 --- .../onap/policy/sdnr/TestPciResponseWrapper.java | 66 ---- .../java/org/onap/policy/sdnr/TestPciStatus.java | 74 ---- .../java/org/onap/policy/sdnr/TestPciWrapper.java | 115 ------ .../onap/policy/sdnr/util/SerializationTest.java | 57 +++ .../onap/policy/sdnr/util/TestSerialization.java | 57 --- .../src/test/java/org/onap/policy/so/DemoTest.java | 186 ++++++++++ .../onap/policy/so/SoAsyncRequestStatusTest.java | 78 ++++ .../onap/policy/so/SoCloudConfigurationTest.java | 48 +++ .../java/org/onap/policy/so/SoDummyServerTest.java | 239 ++++++++++++ .../onap/policy/so/SoInstanceReferencesTest.java | 48 +++ .../java/org/onap/policy/so/SoManagerTest.java | 404 +++++++++++++++++++++ .../java/org/onap/policy/so/SoModelInfoTest.java | 69 ++++ .../policy/so/SoPolicyExceptionHolderTest.java | 48 +++ .../so/SoRelatedInstanceListElementTest.java | 45 +++ .../org/onap/policy/so/SoRelatedInstanceTest.java | 53 +++ .../org/onap/policy/so/SoRequestDetailsTest.java | 174 +++++++++ .../org/onap/policy/so/SoRequestErrorTest.java | 50 +++ .../java/org/onap/policy/so/SoRequestInfoTest.java | 81 +++++ .../onap/policy/so/SoRequestParametersTest.java | 46 +++ .../onap/policy/so/SoRequestReferencesTest.java | 48 +++ .../org/onap/policy/so/SoRequestStatusTest.java | 57 +++ .../java/org/onap/policy/so/SoRequestTest.java | 75 ++++ .../java/org/onap/policy/so/SoResponseTest.java | 59 +++ .../org/onap/policy/so/SoResponseWrapperTest.java | 105 ++++++ .../policy/so/SoServiceExceptionHolderTest.java | 50 +++ .../org/onap/policy/so/SoSubscriberInfoTest.java | 52 +++ .../src/test/java/org/onap/policy/so/TestDemo.java | 186 ---------- .../onap/policy/so/TestSoAsyncRequestStatus.java | 78 ---- .../onap/policy/so/TestSoCloudConfiguration.java | 48 --- .../java/org/onap/policy/so/TestSoDummyServer.java | 239 ------------ .../onap/policy/so/TestSoInstanceReferences.java | 48 --- .../java/org/onap/policy/so/TestSoManager.java | 404 --------------------- .../java/org/onap/policy/so/TestSoModelInfo.java | 69 ---- .../policy/so/TestSoPolicyExceptionHolder.java | 48 --- .../org/onap/policy/so/TestSoRelatedInstance.java | 53 --- .../so/TestSoRelatedInstanceListElement.java | 45 --- .../java/org/onap/policy/so/TestSoRequest.java | 75 ---- .../org/onap/policy/so/TestSoRequestDetails.java | 174 --------- .../org/onap/policy/so/TestSoRequestError.java | 50 --- .../java/org/onap/policy/so/TestSoRequestInfo.java | 81 ----- .../onap/policy/so/TestSoRequestParameters.java | 46 --- .../onap/policy/so/TestSoRequestReferences.java | 48 --- .../org/onap/policy/so/TestSoRequestStatus.java | 57 --- .../java/org/onap/policy/so/TestSoResponse.java | 59 --- .../org/onap/policy/so/TestSoResponseWrapper.java | 105 ------ .../policy/so/TestSoServiceExceptionHolder.java | 50 --- .../org/onap/policy/so/TestSoSubscriberInfo.java | 52 --- .../onap/policy/vnf/trafficgenerator/DemoTest.java | 54 +++ .../onap/policy/vnf/trafficgenerator/TestDemo.java | 54 --- .../test/java/org/onap/policy/vfc/DemoTest.java | 81 +++++ .../test/java/org/onap/policy/vfc/TestDemo.java | 81 ----- .../onap/policy/vfc/TestVfcHealActionVmInfo.java | 48 --- .../policy/vfc/TestVfcHealAdditionalParams.java | 48 --- .../org/onap/policy/vfc/TestVfcHealRequest.java | 52 --- .../java/org/onap/policy/vfc/TestVfcManager.java | 293 --------------- .../java/org/onap/policy/vfc/TestVfcRequest.java | 54 --- .../java/org/onap/policy/vfc/TestVfcResponse.java | 52 --- .../onap/policy/vfc/TestVfcResponseDescriptor.java | 67 ---- .../onap/policy/vfc/VfcHealActionVmInfoTest.java | 48 +++ .../policy/vfc/VfcHealAdditionalParamsTest.java | 48 +++ .../org/onap/policy/vfc/VfcHealRequestTest.java | 52 +++ .../java/org/onap/policy/vfc/VfcManagerTest.java | 293 +++++++++++++++ .../java/org/onap/policy/vfc/VfcRequestTest.java | 54 +++ .../onap/policy/vfc/VfcResponseDescriptorTest.java | 67 ++++ .../java/org/onap/policy/vfc/VfcResponseTest.java | 52 +++ .../onap/policy/vfc/util/SerializationTest.java | 34 ++ .../onap/policy/vfc/util/TestSerialization.java | 34 -- 140 files changed, 6277 insertions(+), 6277 deletions(-) create mode 100644 controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java delete mode 100644 controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActorServiceProvider.java create mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java create mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/EnumsTest.java create mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java create mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java create mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java delete mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestCommonHeader.java delete mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestEnums.java delete mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestRequest.java delete mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponse.java delete mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponseStatus.java create mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/SerializationTest.java delete mode 100644 controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/TestSerialization.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java create mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java delete mode 100644 controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java create mode 100755 controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java create mode 100755 controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PairTest.java create mode 100755 controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java delete mode 100755 controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java delete mode 100755 controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPair.java delete mode 100755 controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java create mode 100644 controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java create mode 100644 controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java create mode 100644 controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java create mode 100644 controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java delete mode 100644 controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestResource.java delete mode 100644 controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestResourceInstance.java delete mode 100644 controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestService.java delete mode 100644 controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestServiceInstance.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealAdditionalParamsTest.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealRequestTest.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealServiceInfoTest.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncRequestTest.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseDescriptorTest.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseTest.java delete mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestDemo.java delete mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealAdditionalParams.java delete mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealRequest.java delete mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealServiceInfo.java delete mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncManager.java delete mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncRequest.java delete mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponse.java delete mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponseDescriptor.java create mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/SerializationTest.java delete mode 100644 controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/TestSerialization.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciCommonHeader.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequest.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequestWrapper.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseCode.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseWrapper.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciStatus.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciWrapper.java create mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java delete mode 100644 controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/TestSerialization.java create mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java create mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java create mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java delete mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java delete mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java delete mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoManager.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyExceptionHolder.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceExceptionHolder.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java create mode 100644 controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/DemoTest.java delete mode 100644 controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java create mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java delete mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java delete mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealActionVmInfo.java delete mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealAdditionalParams.java delete mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealRequest.java delete mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcManager.java delete mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcRequest.java delete mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcResponse.java delete mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcResponseDescriptor.java create mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java create mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java create mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java create mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java create mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java create mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java create mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java create mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/SerializationTest.java delete mode 100644 controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/TestSerialization.java diff --git a/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java b/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java new file mode 100644 index 000000000..a70216d1e --- /dev/null +++ b/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/ActorServiceProviderTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * TestActorServiceProvider + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.controlloop.actorserviceprovider; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; +import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; + +public class ActorServiceProviderTest { + + @Test + public void testActorServiceProvider() { + ActorService actorService = ActorService.getInstance(); + assertNotNull(actorService); + + assertEquals(1, actorService.actors().size()); + + actorService = ActorService.getInstance(); + assertNotNull(actorService); + + Actor testActor = ActorService.getInstance().actors().get(0); + assertNotNull(testActor); + + assertEquals("TestActor", testActor.actor()); + + assertEquals(2, testActor.recipes().size()); + assertEquals("Dorothy", testActor.recipes().get(0)); + assertEquals("Wizard", testActor.recipes().get(1)); + + assertEquals(2, testActor.recipeTargets("Dorothy").size()); + assertEquals(2, testActor.recipePayloads("Dorothy").size()); + } +} diff --git a/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActorServiceProvider.java b/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActorServiceProvider.java deleted file mode 100644 index 1544e1ab4..000000000 --- a/controlloop/common/actors/actorServiceProvider/src/test/java/org/onap/policy/controlloop/actorserviceprovider/TestActorServiceProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * TestActorServiceProvider - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.controlloop.actorserviceprovider; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.onap.policy.controlloop.actorserviceprovider.spi.Actor; - -public class TestActorServiceProvider { - - @Test - public void testActorServiceProvider() { - ActorService actorService = ActorService.getInstance(); - assertNotNull(actorService); - - assertEquals(1, actorService.actors().size()); - - actorService = ActorService.getInstance(); - assertNotNull(actorService); - - Actor testActor = ActorService.getInstance().actors().get(0); - assertNotNull(testActor); - - assertEquals("TestActor", testActor.actor()); - - assertEquals(2, testActor.recipes().size()); - assertEquals("Dorothy", testActor.recipes().get(0)); - assertEquals("Wizard", testActor.recipes().get(1)); - - assertEquals(2, testActor.recipeTargets("Dorothy").size()); - assertEquals(2, testActor.recipePayloads("Dorothy").size()); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java new file mode 100644 index 000000000..93a05f424 --- /dev/null +++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/CommonHeaderTest.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.junit.Test; + +public class CommonHeaderTest { + + @Test + public void testCommonHeader() { + CommonHeader commonHeader = new CommonHeader(); + assertNotNull(commonHeader); + assertNotNull(new CommonHeader(commonHeader)); + assertNotEquals(0, commonHeader.hashCode()); + + commonHeader.setApiVer("Kansas"); + assertEquals("Kansas", commonHeader.getApiVer()); + + List> flagSet = new ArrayList<>(); + commonHeader.setFlags(flagSet); + assertEquals(flagSet, commonHeader.getFlags()); + + commonHeader.setOriginatorId("Dorothy"); + assertEquals("Dorothy", commonHeader.getOriginatorId()); + + UUID requestId = UUID.randomUUID(); + commonHeader.setRequestId(requestId); + assertEquals(requestId, commonHeader.getRequestId()); + + List requestTrackSet = new ArrayList<>(); + commonHeader.setRequestTrack(requestTrackSet); + assertEquals(requestTrackSet, commonHeader.getRequestTrack()); + + commonHeader.setSubRequestId("Can I go home?"); + assertEquals("Can I go home?", commonHeader.getSubRequestId()); + + Instant timestamp = Instant.now(); + commonHeader.setTimeStamp(timestamp); + assertEquals(timestamp, commonHeader.getTimeStamp()); + + assertNotEquals(0, commonHeader.hashCode()); + + assertEquals("CommonHeader [TimeStamp=", commonHeader.toString().substring(0, 24)); + + CommonHeader copiedCommonHeader = new CommonHeader(); + copiedCommonHeader.setApiVer(commonHeader.getApiVer()); + copiedCommonHeader.setFlags(commonHeader.getFlags()); + copiedCommonHeader.setOriginatorId(commonHeader.getOriginatorId()); + copiedCommonHeader.setRequestId(commonHeader.getRequestId()); + copiedCommonHeader.setRequestTrack(commonHeader.getRequestTrack()); + copiedCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); + copiedCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); + + assertTrue(commonHeader.equals(commonHeader)); + assertTrue(commonHeader.equals(copiedCommonHeader)); + assertFalse(commonHeader.equals(null)); + assertFalse(commonHeader.equals("Hello")); + + CommonHeader clonedCommonHeader = new CommonHeader(commonHeader); + clonedCommonHeader.setApiVer(commonHeader.getApiVer()); + clonedCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); + + assertTrue(commonHeader.equals(clonedCommonHeader)); + + commonHeader.setApiVer(null); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setApiVer(null); + assertTrue(commonHeader.equals(copiedCommonHeader)); + commonHeader.setApiVer("Kansas"); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setApiVer("Kansas"); + assertTrue(commonHeader.equals(copiedCommonHeader)); + + commonHeader.setFlags(null); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setFlags(null); + assertTrue(commonHeader.equals(copiedCommonHeader)); + commonHeader.setFlags(flagSet); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setFlags(flagSet); + assertTrue(commonHeader.equals(copiedCommonHeader)); + + commonHeader.setOriginatorId(null); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setOriginatorId(null); + assertTrue(commonHeader.equals(copiedCommonHeader)); + commonHeader.setOriginatorId("Dorothy"); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setOriginatorId("Dorothy"); + assertTrue(commonHeader.equals(copiedCommonHeader)); + + commonHeader.setRequestId(null); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setRequestId(null); + assertTrue(commonHeader.equals(copiedCommonHeader)); + commonHeader.setRequestId(requestId); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setRequestId(requestId); + assertTrue(commonHeader.equals(copiedCommonHeader)); + + commonHeader.setRequestTrack(null); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setRequestTrack(null); + assertTrue(commonHeader.equals(copiedCommonHeader)); + commonHeader.setRequestTrack(requestTrackSet); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setRequestTrack(requestTrackSet); + assertTrue(commonHeader.equals(copiedCommonHeader)); + + commonHeader.setSubRequestId(null); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setSubRequestId(null); + assertTrue(commonHeader.equals(copiedCommonHeader)); + commonHeader.setSubRequestId("Can I go home?"); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setSubRequestId("Can I go home?"); + assertTrue(commonHeader.equals(copiedCommonHeader)); + + commonHeader.setTimeStamp(null); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setTimeStamp(null); + assertTrue(commonHeader.equals(copiedCommonHeader)); + commonHeader.setTimeStamp(timestamp); + assertFalse(commonHeader.equals(copiedCommonHeader)); + copiedCommonHeader.setTimeStamp(timestamp); + assertTrue(commonHeader.equals(copiedCommonHeader)); + } +} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/EnumsTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/EnumsTest.java new file mode 100644 index 000000000..afb9a312e --- /dev/null +++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/EnumsTest.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +public class EnumsTest { + + @Test + public void testResponseCode() { + assertEquals(5, ResponseCode.values().length); + + assertNull(ResponseCode.toResponseCode(0)); + + assertEquals(ResponseCode.ACCEPT, ResponseCode.toResponseCode(100)); + assertEquals(ResponseCode.ERROR, ResponseCode.toResponseCode(200)); + assertEquals(ResponseCode.REJECT, ResponseCode.toResponseCode(300)); + assertEquals(ResponseCode.SUCCESS, ResponseCode.toResponseCode(400)); + assertEquals(ResponseCode.FAILURE, ResponseCode.toResponseCode(500)); + + assertEquals(100, ResponseCode.ACCEPT.getValue()); + assertEquals(200, ResponseCode.ERROR.getValue()); + assertEquals(300, ResponseCode.REJECT.getValue()); + assertEquals(400, ResponseCode.SUCCESS.getValue()); + assertEquals(500, ResponseCode.FAILURE.getValue()); + + assertEquals("100", ResponseCode.ACCEPT.toString()); + assertEquals("200", ResponseCode.ERROR.toString()); + assertEquals("300", ResponseCode.REJECT.toString()); + assertEquals("400", ResponseCode.SUCCESS.toString()); + assertEquals("500", ResponseCode.FAILURE.toString()); + } + + @Test + public void testResponseValue() { + assertEquals(5, ResponseValue.values().length); + + assertNull(ResponseValue.toResponseValue("Dorothy")); + assertNull(ResponseValue.toResponseValue(null)); + + assertEquals(ResponseValue.ACCEPT, ResponseValue.toResponseValue("ACCEPT")); + assertEquals(ResponseValue.ERROR, ResponseValue.toResponseValue("ERROR")); + assertEquals(ResponseValue.REJECT, ResponseValue.toResponseValue("REJECT")); + assertEquals(ResponseValue.SUCCESS, ResponseValue.toResponseValue("SUCCESS")); + assertEquals(ResponseValue.FAILURE, ResponseValue.toResponseValue("FAILURE")); + + assertEquals("ACCEPT", ResponseValue.ACCEPT.toString()); + assertEquals("ERROR", ResponseValue.ERROR.toString()); + assertEquals("REJECT", ResponseValue.REJECT.toString()); + assertEquals("SUCCESS", ResponseValue.SUCCESS.toString()); + assertEquals("FAILURE", ResponseValue.FAILURE.toString()); + } +} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java new file mode 100644 index 000000000..e0c850b60 --- /dev/null +++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/RequestTest.java @@ -0,0 +1,124 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class RequestTest { + + @Test + public void testRequest() { + Request request = new Request(); + assertNotNull(request); + assertNotEquals(0, request.hashCode()); + + CommonHeader commonHeader = new CommonHeader(); + + request.setCommonHeader(commonHeader); + assertEquals(commonHeader, request.getCommonHeader()); + + request.setAction("Go to Oz"); + assertEquals("Go to Oz", request.getAction()); + + request.setObjectId("Wizard"); + assertEquals("Wizard", request.getObjectId()); + + request.setTargetId("Oz"); + assertEquals("Oz", request.getTargetId()); + + Map payload = new HashMap<>(); + payload.put("North", "Good Witch"); + payload.put("West", "Bad Witch"); + + request.setPayload(payload); + assertEquals(payload, request.getPayload()); + + assertNotEquals(0, request.hashCode()); + + assertEquals("Request [CommonHeader=CommonHeader [TimeStamp=", request.toString().substring(0, 46)); + + Request copiedRequest = new Request(); + copiedRequest.setCommonHeader(request.getCommonHeader()); + copiedRequest.setAction(request.getAction()); + copiedRequest.setObjectId(request.getObjectId()); + copiedRequest.setPayload(request.getPayload()); + copiedRequest.setTargetId(request.getTargetId()); + + assertTrue(request.equals(request)); + assertTrue(request.equals(copiedRequest)); + assertFalse(request.equals(null)); + assertFalse(request.equals("Hello")); + + request.setCommonHeader(null); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setCommonHeader(null); + assertTrue(request.equals(copiedRequest)); + request.setCommonHeader(commonHeader); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setCommonHeader(commonHeader); + assertTrue(request.equals(copiedRequest)); + + request.setAction(null); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setAction(null); + assertTrue(request.equals(copiedRequest)); + request.setAction("Go to Oz"); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setAction("Go to Oz"); + assertTrue(request.equals(copiedRequest)); + + request.setObjectId(null); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setObjectId(null); + assertTrue(request.equals(copiedRequest)); + request.setObjectId("Wizard"); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setObjectId("Wizard"); + assertTrue(request.equals(copiedRequest)); + + request.setTargetId(null); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setTargetId(null); + assertTrue(request.equals(copiedRequest)); + request.setTargetId("Oz"); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setTargetId("Oz"); + assertTrue(request.equals(copiedRequest)); + + request.setPayload(new HashMap()); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setPayload(new HashMap()); + assertTrue(request.equals(copiedRequest)); + request.setPayload(payload); + assertFalse(request.equals(copiedRequest)); + copiedRequest.setPayload(payload); + assertTrue(request.equals(copiedRequest)); + } +} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java new file mode 100644 index 000000000..ab8811d37 --- /dev/null +++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseStatusTest.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class ResponseStatusTest { + + @Test + public void testResonseStatus() { + ResponseStatus status = new ResponseStatus(); + assertNotNull(status); + assertNotEquals(0, status.hashCode()); + + status.setCode(1234); + assertEquals(1234, status.getCode()); + + status.setDescription("The wonderful land of Oz"); + assertEquals("The wonderful land of Oz", status.getDescription()); + + status.setValue("There's no place like home"); + assertEquals("There's no place like home", status.getValue()); + assertNotEquals(0, status.hashCode()); + + assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47)); + + ResponseStatus copiedStatus = new ResponseStatus(); + copiedStatus.setCode(status.getCode()); + copiedStatus.setDescription(status.getDescription()); + copiedStatus.setValue(status.getValue()); + + assertTrue(status.equals(status)); + assertTrue(status.equals(copiedStatus)); + assertFalse(status.equals(null)); + assertFalse(status.equals("Hello")); + + status.setCode(-1); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setCode(-1); + assertTrue(status.equals(copiedStatus)); + status.setCode(1234); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setCode(1234); + assertTrue(status.equals(copiedStatus)); + + status.setDescription(null); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setDescription(null); + assertTrue(status.equals(copiedStatus)); + status.setDescription("The wonderful land of Oz"); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setDescription("The wonderful land of Oz"); + assertTrue(status.equals(copiedStatus)); + + status.setValue(null); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setValue(null); + assertTrue(status.equals(copiedStatus)); + status.setValue("There's no place like home"); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setValue("There's no place like home"); + assertTrue(status.equals(copiedStatus)); + } +} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java new file mode 100644 index 000000000..ce0ba90a5 --- /dev/null +++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/ResponseTest.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class ResponseTest { + + @Test + public void testResonse() { + Response response = new Response(); + assertNotNull(response); + assertNotNull(new Response(new Request())); + assertNotEquals(0, response.hashCode()); + + CommonHeader commonHeader = new CommonHeader(); + + Request request = new Request(); + request.setCommonHeader(commonHeader); + assertNotNull(new Response(request)); + + response.setCommonHeader(commonHeader); + assertEquals(commonHeader, response.getCommonHeader()); + + ResponseStatus status = new ResponseStatus(); + response.setStatus(status); + assertEquals(status, response.getStatus()); + + Map payload = new HashMap<>(); + payload.put("North", "Good Witch"); + payload.put("West", "Bad Witch"); + + response.setPayload(payload); + assertEquals(payload, response.getPayload()); + + assertNotEquals(0, response.hashCode()); + + assertEquals("Response [CommonHeader=CommonHeader [TimeStamp=", response.toString().substring(0, 47)); + + Response copiedResponse = new Response(); + copiedResponse.setCommonHeader(response.getCommonHeader()); + copiedResponse.setStatus(response.getStatus()); + copiedResponse.setPayload(response.getPayload()); + + assertTrue(response.equals(response)); + assertTrue(response.equals(copiedResponse)); + assertFalse(response.equals(null)); + assertFalse(response.equals("Hello")); + + response.setCommonHeader(null); + assertFalse(response.equals(copiedResponse)); + copiedResponse.setCommonHeader(null); + assertTrue(response.equals(copiedResponse)); + response.setCommonHeader(commonHeader); + assertFalse(response.equals(copiedResponse)); + copiedResponse.setCommonHeader(commonHeader); + assertTrue(response.equals(copiedResponse)); + + response.setStatus(null); + assertFalse(response.equals(copiedResponse)); + copiedResponse.setStatus(null); + assertTrue(response.equals(copiedResponse)); + response.setStatus(status); + assertFalse(response.equals(copiedResponse)); + copiedResponse.setStatus(status); + assertTrue(response.equals(copiedResponse)); + + response.setPayload(new HashMap()); + assertFalse(response.equals(copiedResponse)); + copiedResponse.setPayload(new HashMap()); + assertTrue(response.equals(copiedResponse)); + response.setPayload(payload); + assertFalse(response.equals(copiedResponse)); + copiedResponse.setPayload(payload); + assertTrue(response.equals(copiedResponse)); + } +} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestCommonHeader.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestCommonHeader.java deleted file mode 100644 index 2e456bca0..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestCommonHeader.java +++ /dev/null @@ -1,178 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; - -public class TestCommonHeader { - - @Test - public void testCommonHeader() { - CommonHeader commonHeader = new CommonHeader(); - assertNotNull(commonHeader); - assertNotNull(new CommonHeader(commonHeader)); - assertNotEquals(0, commonHeader.hashCode()); - - commonHeader.setApiVer("Kansas"); - assertEquals("Kansas", commonHeader.getApiVer()); - - List> flagSet = new ArrayList<>(); - commonHeader.setFlags(flagSet); - assertEquals(flagSet, commonHeader.getFlags()); - - commonHeader.setOriginatorId("Dorothy"); - assertEquals("Dorothy", commonHeader.getOriginatorId()); - - UUID requestId = UUID.randomUUID(); - commonHeader.setRequestId(requestId); - assertEquals(requestId, commonHeader.getRequestId()); - - List requestTrackSet = new ArrayList<>(); - commonHeader.setRequestTrack(requestTrackSet); - assertEquals(requestTrackSet, commonHeader.getRequestTrack()); - - commonHeader.setSubRequestId("Can I go home?"); - assertEquals("Can I go home?", commonHeader.getSubRequestId()); - - Instant timestamp = Instant.now(); - commonHeader.setTimeStamp(timestamp); - assertEquals(timestamp, commonHeader.getTimeStamp()); - - assertNotEquals(0, commonHeader.hashCode()); - - assertEquals("CommonHeader [TimeStamp=", commonHeader.toString().substring(0, 24)); - - CommonHeader copiedCommonHeader = new CommonHeader(); - copiedCommonHeader.setApiVer(commonHeader.getApiVer()); - copiedCommonHeader.setFlags(commonHeader.getFlags()); - copiedCommonHeader.setOriginatorId(commonHeader.getOriginatorId()); - copiedCommonHeader.setRequestId(commonHeader.getRequestId()); - copiedCommonHeader.setRequestTrack(commonHeader.getRequestTrack()); - copiedCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); - copiedCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); - - CommonHeader clonedCommonHeader = new CommonHeader(commonHeader); - clonedCommonHeader.setApiVer(commonHeader.getApiVer()); - clonedCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(clonedCommonHeader)); - - commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setApiVer("Kansas"); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setApiVer("Kansas"); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setFlags(flagSet); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setFlags(flagSet); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setOriginatorId(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setOriginatorId(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setOriginatorId("Dorothy"); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setOriginatorId("Dorothy"); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setRequestTrack(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setRequestTrack(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setRequestTrack(requestTrackSet); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setRequestTrack(requestTrackSet); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setSubRequestId("Can I go home?"); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setSubRequestId("Can I go home?"); - assertTrue(commonHeader.equals(copiedCommonHeader)); - - commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedCommonHeader)); - commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedCommonHeader)); - copiedCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedCommonHeader)); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestEnums.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestEnums.java deleted file mode 100644 index 95adec84f..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestEnums.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class TestEnums { - - @Test - public void testResponseCode() { - assertEquals(5, ResponseCode.values().length); - - assertNull(ResponseCode.toResponseCode(0)); - - assertEquals(ResponseCode.ACCEPT, ResponseCode.toResponseCode(100)); - assertEquals(ResponseCode.ERROR, ResponseCode.toResponseCode(200)); - assertEquals(ResponseCode.REJECT, ResponseCode.toResponseCode(300)); - assertEquals(ResponseCode.SUCCESS, ResponseCode.toResponseCode(400)); - assertEquals(ResponseCode.FAILURE, ResponseCode.toResponseCode(500)); - - assertEquals(100, ResponseCode.ACCEPT.getValue()); - assertEquals(200, ResponseCode.ERROR.getValue()); - assertEquals(300, ResponseCode.REJECT.getValue()); - assertEquals(400, ResponseCode.SUCCESS.getValue()); - assertEquals(500, ResponseCode.FAILURE.getValue()); - - assertEquals("100", ResponseCode.ACCEPT.toString()); - assertEquals("200", ResponseCode.ERROR.toString()); - assertEquals("300", ResponseCode.REJECT.toString()); - assertEquals("400", ResponseCode.SUCCESS.toString()); - assertEquals("500", ResponseCode.FAILURE.toString()); - } - - @Test - public void testResponseValue() { - assertEquals(5, ResponseValue.values().length); - - assertNull(ResponseValue.toResponseValue("Dorothy")); - assertNull(ResponseValue.toResponseValue(null)); - - assertEquals(ResponseValue.ACCEPT, ResponseValue.toResponseValue("ACCEPT")); - assertEquals(ResponseValue.ERROR, ResponseValue.toResponseValue("ERROR")); - assertEquals(ResponseValue.REJECT, ResponseValue.toResponseValue("REJECT")); - assertEquals(ResponseValue.SUCCESS, ResponseValue.toResponseValue("SUCCESS")); - assertEquals(ResponseValue.FAILURE, ResponseValue.toResponseValue("FAILURE")); - - assertEquals("ACCEPT", ResponseValue.ACCEPT.toString()); - assertEquals("ERROR", ResponseValue.ERROR.toString()); - assertEquals("REJECT", ResponseValue.REJECT.toString()); - assertEquals("SUCCESS", ResponseValue.SUCCESS.toString()); - assertEquals("FAILURE", ResponseValue.FAILURE.toString()); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestRequest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestRequest.java deleted file mode 100644 index 462fb7a01..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestRequest.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -public class TestRequest { - - @Test - public void testRequest() { - Request request = new Request(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - CommonHeader commonHeader = new CommonHeader(); - - request.setCommonHeader(commonHeader); - assertEquals(commonHeader, request.getCommonHeader()); - - request.setAction("Go to Oz"); - assertEquals("Go to Oz", request.getAction()); - - request.setObjectId("Wizard"); - assertEquals("Wizard", request.getObjectId()); - - request.setTargetId("Oz"); - assertEquals("Oz", request.getTargetId()); - - Map payload = new HashMap<>(); - payload.put("North", "Good Witch"); - payload.put("West", "Bad Witch"); - - request.setPayload(payload); - assertEquals(payload, request.getPayload()); - - assertNotEquals(0, request.hashCode()); - - assertEquals("Request [CommonHeader=CommonHeader [TimeStamp=", request.toString().substring(0, 46)); - - Request copiedRequest = new Request(); - copiedRequest.setCommonHeader(request.getCommonHeader()); - copiedRequest.setAction(request.getAction()); - copiedRequest.setObjectId(request.getObjectId()); - copiedRequest.setPayload(request.getPayload()); - copiedRequest.setTargetId(request.getTargetId()); - - assertTrue(request.equals(request)); - assertTrue(request.equals(copiedRequest)); - assertFalse(request.equals(null)); - assertFalse(request.equals("Hello")); - - request.setCommonHeader(null); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setCommonHeader(null); - assertTrue(request.equals(copiedRequest)); - request.setCommonHeader(commonHeader); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setCommonHeader(commonHeader); - assertTrue(request.equals(copiedRequest)); - - request.setAction(null); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setAction(null); - assertTrue(request.equals(copiedRequest)); - request.setAction("Go to Oz"); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setAction("Go to Oz"); - assertTrue(request.equals(copiedRequest)); - - request.setObjectId(null); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setObjectId(null); - assertTrue(request.equals(copiedRequest)); - request.setObjectId("Wizard"); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setObjectId("Wizard"); - assertTrue(request.equals(copiedRequest)); - - request.setTargetId(null); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setTargetId(null); - assertTrue(request.equals(copiedRequest)); - request.setTargetId("Oz"); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setTargetId("Oz"); - assertTrue(request.equals(copiedRequest)); - - request.setPayload(new HashMap()); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setPayload(new HashMap()); - assertTrue(request.equals(copiedRequest)); - request.setPayload(payload); - assertFalse(request.equals(copiedRequest)); - copiedRequest.setPayload(payload); - assertTrue(request.equals(copiedRequest)); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponse.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponse.java deleted file mode 100644 index bf5fec86a..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponse.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -public class TestResponse { - - @Test - public void testResonse() { - Response response = new Response(); - assertNotNull(response); - assertNotNull(new Response(new Request())); - assertNotEquals(0, response.hashCode()); - - CommonHeader commonHeader = new CommonHeader(); - - Request request = new Request(); - request.setCommonHeader(commonHeader); - assertNotNull(new Response(request)); - - response.setCommonHeader(commonHeader); - assertEquals(commonHeader, response.getCommonHeader()); - - ResponseStatus status = new ResponseStatus(); - response.setStatus(status); - assertEquals(status, response.getStatus()); - - Map payload = new HashMap<>(); - payload.put("North", "Good Witch"); - payload.put("West", "Bad Witch"); - - response.setPayload(payload); - assertEquals(payload, response.getPayload()); - - assertNotEquals(0, response.hashCode()); - - assertEquals("Response [CommonHeader=CommonHeader [TimeStamp=", response.toString().substring(0, 47)); - - Response copiedResponse = new Response(); - copiedResponse.setCommonHeader(response.getCommonHeader()); - copiedResponse.setStatus(response.getStatus()); - copiedResponse.setPayload(response.getPayload()); - - assertTrue(response.equals(response)); - assertTrue(response.equals(copiedResponse)); - assertFalse(response.equals(null)); - assertFalse(response.equals("Hello")); - - response.setCommonHeader(null); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setCommonHeader(null); - assertTrue(response.equals(copiedResponse)); - response.setCommonHeader(commonHeader); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setCommonHeader(commonHeader); - assertTrue(response.equals(copiedResponse)); - - response.setStatus(null); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setStatus(null); - assertTrue(response.equals(copiedResponse)); - response.setStatus(status); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setStatus(status); - assertTrue(response.equals(copiedResponse)); - - response.setPayload(new HashMap()); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setPayload(new HashMap()); - assertTrue(response.equals(copiedResponse)); - response.setPayload(payload); - assertFalse(response.equals(copiedResponse)); - copiedResponse.setPayload(payload); - assertTrue(response.equals(copiedResponse)); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponseStatus.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponseStatus.java deleted file mode 100644 index 46d8a0b25..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/TestResponseStatus.java +++ /dev/null @@ -1,88 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestResponseStatus { - - @Test - public void testResonseStatus() { - ResponseStatus status = new ResponseStatus(); - assertNotNull(status); - assertNotEquals(0, status.hashCode()); - - status.setCode(1234); - assertEquals(1234, status.getCode()); - - status.setDescription("The wonderful land of Oz"); - assertEquals("The wonderful land of Oz", status.getDescription()); - - status.setValue("There's no place like home"); - assertEquals("There's no place like home", status.getValue()); - assertNotEquals(0, status.hashCode()); - - assertEquals("ResponseStatus [Code=1234, Value=There's no pla", status.toString().substring(0, 47)); - - ResponseStatus copiedStatus = new ResponseStatus(); - copiedStatus.setCode(status.getCode()); - copiedStatus.setDescription(status.getDescription()); - copiedStatus.setValue(status.getValue()); - - assertTrue(status.equals(status)); - assertTrue(status.equals(copiedStatus)); - assertFalse(status.equals(null)); - assertFalse(status.equals("Hello")); - - status.setCode(-1); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(-1); - assertTrue(status.equals(copiedStatus)); - status.setCode(1234); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(1234); - assertTrue(status.equals(copiedStatus)); - - status.setDescription(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setDescription(null); - assertTrue(status.equals(copiedStatus)); - status.setDescription("The wonderful land of Oz"); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setDescription("The wonderful land of Oz"); - assertTrue(status.equals(copiedStatus)); - - status.setValue(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue(null); - assertTrue(status.equals(copiedStatus)); - status.setValue("There's no place like home"); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue("There's no place like home"); - assertTrue(status.equals(copiedStatus)); - } -} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/SerializationTest.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/SerializationTest.java new file mode 100644 index 000000000..6a3a3a099 --- /dev/null +++ b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/SerializationTest.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appc.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +import org.junit.Test; + +public class SerializationTest { + + @Test + public void test() { + String nameString = "Dorothy"; + String jsonName = Serialization.gsonPretty.toJson(nameString, String.class); + assertEquals("\"Dorothy\"", jsonName); + String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class); + assertEquals("Dorothy", jsonInOutName); + + Instant instant = Instant.ofEpochMilli(1516127215000L); + String instantString = Serialization.gsonPretty.toJson(instant, Instant.class); + assertEquals("1516127215000", instantString); + Instant outInstant = Serialization.gsonPretty.fromJson(instantString, Instant.class); + assertEquals(instant, outInstant); + + ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC")); + String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class); + assertEquals("\"2018-01-16 18:26:55.000000+00:00\"", zdtString); + ZonedDateTime outZdt = Serialization.gsonPretty.fromJson(zdtString, ZonedDateTime.class); + assertEquals(zdt.getDayOfWeek(), outZdt.getDayOfWeek()); + + assertNull(Serialization.gsonPretty.fromJson("oz time is weird", ZonedDateTime.class)); + } +} diff --git a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/TestSerialization.java b/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/TestSerialization.java deleted file mode 100644 index ae1890acf..000000000 --- a/controlloop/common/model-impl/appc/src/test/java/org/onap/policy/appc/util/TestSerialization.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appc.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; - -import org.junit.Test; - -public class TestSerialization { - - @Test - public void test() { - String nameString = "Dorothy"; - String jsonName = Serialization.gsonPretty.toJson(nameString, String.class); - assertEquals("\"Dorothy\"", jsonName); - String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class); - assertEquals("Dorothy", jsonInOutName); - - Instant instant = Instant.ofEpochMilli(1516127215000L); - String instantString = Serialization.gsonPretty.toJson(instant, Instant.class); - assertEquals("1516127215000", instantString); - Instant outInstant = Serialization.gsonPretty.fromJson(instantString, Instant.class); - assertEquals(instant, outInstant); - - ZonedDateTime zdt = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC")); - String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class); - assertEquals("\"2018-01-16 18:26:55.000000+00:00\"", zdtString); - ZonedDateTime outZdt = Serialization.gsonPretty.fromJson(zdtString, ZonedDateTime.class); - assertEquals(zdt.getDayOfWeek(), outZdt.getDayOfWeek()); - - assertNull(Serialization.gsonPretty.fromJson("oz time is weird", ZonedDateTime.class)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java new file mode 100644 index 000000000..d48771a5c --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmCommonHeaderTest.java @@ -0,0 +1,143 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.time.Instant; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.junit.Test; + +public class LcmCommonHeaderTest { + + @Test + public void testLcmCommonHeader() { + LcmCommonHeader commonHeader = new LcmCommonHeader(); + assertNotNull(commonHeader); + assertNotNull(new LcmCommonHeader(commonHeader)); + assertNotEquals(0, commonHeader.hashCode()); + + commonHeader.setApiVer("Kansas"); + assertEquals("Kansas", commonHeader.getApiVer()); + + Map flagMap = new HashMap<>(); + commonHeader.setFlags(flagMap); + assertEquals(flagMap, commonHeader.getFlags()); + + commonHeader.setOriginatorId("Dorothy"); + assertEquals("Dorothy", commonHeader.getOriginatorId()); + + UUID requestId = UUID.randomUUID(); + commonHeader.setRequestId(requestId); + assertEquals(requestId, commonHeader.getRequestId()); + + commonHeader.setSubRequestId("Can I go home?"); + assertEquals("Can I go home?", commonHeader.getSubRequestId()); + + Instant timestamp = Instant.now(); + commonHeader.setTimeStamp(timestamp); + assertEquals(timestamp, commonHeader.getTimeStamp()); + + assertNotEquals(0, commonHeader.hashCode()); + + assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24)); + + LcmCommonHeader copiedLcmCommonHeader = new LcmCommonHeader(); + copiedLcmCommonHeader.setApiVer(commonHeader.getApiVer()); + copiedLcmCommonHeader.setFlags(commonHeader.getFlags()); + copiedLcmCommonHeader.setOriginatorId(commonHeader.getOriginatorId()); + copiedLcmCommonHeader.setRequestId(commonHeader.getRequestId()); + copiedLcmCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); + copiedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); + + assertTrue(commonHeader.equals(commonHeader)); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + assertFalse(commonHeader.equals(null)); + assertFalse(commonHeader.equals("Hello")); + + LcmCommonHeader clonedLcmCommonHeader = new LcmCommonHeader(commonHeader); + clonedLcmCommonHeader.setApiVer(commonHeader.getApiVer()); + clonedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); + + assertTrue(commonHeader.equals(clonedLcmCommonHeader)); + + commonHeader.setApiVer(null); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setApiVer(null); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + commonHeader.setApiVer("Kansas"); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setApiVer("Kansas"); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + + commonHeader.setFlags(null); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setFlags(null); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + commonHeader.setFlags(flagMap); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setFlags(flagMap); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + + commonHeader.setOriginatorId(null); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setOriginatorId(null); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + commonHeader.setOriginatorId("Dorothy"); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setOriginatorId("Dorothy"); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + + commonHeader.setRequestId(null); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setRequestId(null); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + commonHeader.setRequestId(requestId); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setRequestId(requestId); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + + commonHeader.setSubRequestId(null); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setSubRequestId(null); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + commonHeader.setSubRequestId("Can I go home?"); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setSubRequestId("Can I go home?"); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + + commonHeader.setTimeStamp(null); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setTimeStamp(null); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + commonHeader.setTimeStamp(timestamp); + assertFalse(commonHeader.equals(copiedLcmCommonHeader)); + copiedLcmCommonHeader.setTimeStamp(timestamp); + assertTrue(commonHeader.equals(copiedLcmCommonHeader)); + } +} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java new file mode 100644 index 000000000..5cc817d5e --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestTest.java @@ -0,0 +1,111 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; + +public class LcmRequestTest { + + @Test + public void testLcmRequest() { + LcmRequest request = new LcmRequest(); + assertNotNull(request); + assertNotEquals(0, request.hashCode()); + + LcmCommonHeader commonHeader = new LcmCommonHeader(); + + request.setCommonHeader(commonHeader); + assertEquals(commonHeader, request.getCommonHeader()); + + request.setAction("Go to Oz"); + assertEquals("Go to Oz", request.getAction()); + + Map actionIdentifiers = new HashMap<>(); + actionIdentifiers.put("North", "Good Witch"); + actionIdentifiers.put("West", "Bad Witch"); + + request.setActionIdentifiers(actionIdentifiers); + assertEquals(actionIdentifiers, request.getActionIdentifiers()); + + request.setPayload("The Emerald City"); + assertEquals("The Emerald City", request.getPayload()); + + assertNotEquals(0, request.hashCode()); + + assertEquals("Request [commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 46)); + + LcmRequest copiedLcmRequest = new LcmRequest(); + copiedLcmRequest.setCommonHeader(request.getCommonHeader()); + copiedLcmRequest.setAction(request.getAction()); + copiedLcmRequest.setActionIdentifiers(request.getActionIdentifiers()); + copiedLcmRequest.setPayload(request.getPayload()); + + assertTrue(request.equals(request)); + assertTrue(request.equals(copiedLcmRequest)); + assertFalse(request.equals(null)); + assertFalse(request.equals("Hello")); + + request.setCommonHeader(null); + assertFalse(request.equals(copiedLcmRequest)); + copiedLcmRequest.setCommonHeader(null); + assertTrue(request.equals(copiedLcmRequest)); + request.setCommonHeader(commonHeader); + assertFalse(request.equals(copiedLcmRequest)); + copiedLcmRequest.setCommonHeader(commonHeader); + assertTrue(request.equals(copiedLcmRequest)); + + request.setAction(null); + assertFalse(request.equals(copiedLcmRequest)); + copiedLcmRequest.setAction(null); + assertTrue(request.equals(copiedLcmRequest)); + request.setAction("Go to Oz"); + assertFalse(request.equals(copiedLcmRequest)); + copiedLcmRequest.setAction("Go to Oz"); + assertTrue(request.equals(copiedLcmRequest)); + + request.setActionIdentifiers(null); + assertFalse(request.equals(copiedLcmRequest)); + copiedLcmRequest.setActionIdentifiers(null); + assertTrue(request.equals(copiedLcmRequest)); + request.setActionIdentifiers(actionIdentifiers); + assertFalse(request.equals(copiedLcmRequest)); + copiedLcmRequest.setActionIdentifiers(actionIdentifiers); + assertTrue(request.equals(copiedLcmRequest)); + + request.setPayload(null); + assertFalse(request.equals(copiedLcmRequest)); + copiedLcmRequest.setPayload(null); + assertTrue(request.equals(copiedLcmRequest)); + request.setPayload("The Emerald City"); + assertFalse(request.equals(copiedLcmRequest)); + copiedLcmRequest.setPayload("The Emerald City"); + assertTrue(request.equals(copiedLcmRequest)); + } +} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java new file mode 100644 index 000000000..42bb91876 --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmRequestWrapperTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class LcmRequestWrapperTest { + + @Test + public void testLcmRequestWrapperWrapper() { + assertNotNull(new LcmRequestWrapper(new LcmRequest())); + LcmRequestWrapper requestWrapper = new LcmRequestWrapper(); + assertNotNull(requestWrapper); + assertNotEquals(0, requestWrapper.hashCode()); + + LcmRequest request = new LcmRequest(); + + requestWrapper.setBody(request); + assertEquals(request, requestWrapper.getBody()); + + assertNotEquals(0, requestWrapper.hashCode()); + + assertEquals("RequestWrapper [body=Request [commonHeader=nul", requestWrapper.toString().substring(0, 46)); + + LcmRequestWrapper copiedLcmRequestWrapper = new LcmRequestWrapper(); + copiedLcmRequestWrapper.setBody(requestWrapper.getBody()); + + assertTrue(requestWrapper.equals(requestWrapper)); + assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); + assertFalse(requestWrapper.equals(null)); + assertFalse(requestWrapper.equals("Hello")); + + requestWrapper.setBody(null); + assertFalse(requestWrapper.equals(copiedLcmRequestWrapper)); + copiedLcmRequestWrapper.setBody(null); + assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); + requestWrapper.setBody(request); + assertFalse(requestWrapper.equals(copiedLcmRequestWrapper)); + copiedLcmRequestWrapper.setBody(request); + assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); + } +} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java new file mode 100644 index 000000000..b83fc8d79 --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResonseCodeTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +public class LcmResonseCodeTest { + + @Test + public void testLcmResponseCode() { + assertNull(LcmResponseCode.toResponseValue(0)); + + assertEquals(LcmResponseCode.ACCEPTED, LcmResponseCode.toResponseValue(100)); + assertEquals(LcmResponseCode.ERROR, LcmResponseCode.toResponseValue(200)); + assertEquals(LcmResponseCode.REJECT, LcmResponseCode.toResponseValue(300)); + assertEquals(LcmResponseCode.SUCCESS, LcmResponseCode.toResponseValue(400)); + assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(450)); + assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(401)); + assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(406)); + assertEquals(LcmResponseCode.PARTIAL_SUCCESS, LcmResponseCode.toResponseValue(500)); + assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(501)); + assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(599)); + + assertEquals("100", new LcmResponseCode(100).toString()); + assertEquals("200", new LcmResponseCode(200).toString()); + assertEquals("300", new LcmResponseCode(300).toString()); + assertEquals("400", new LcmResponseCode(400).toString()); + assertEquals("450", new LcmResponseCode(450).toString()); + assertEquals("500", new LcmResponseCode(500).toString()); + assertEquals("510", new LcmResponseCode(510).toString()); + + assertEquals(300, new LcmResponseCode(300).getCode()); + } +} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java new file mode 100644 index 000000000..c1a78e10a --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseStatusTest.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class LcmResponseStatusTest { + + @Test + public void testResonseStatus() { + LcmResponseStatus status = new LcmResponseStatus(); + assertNotNull(status); + assertNotEquals(0, status.hashCode()); + + status.setCode(1234); + assertEquals(1234, status.getCode()); + + status.setMessage("The wonderful land of Oz"); + assertEquals("The wonderful land of Oz", status.getMessage()); + + assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47)); + + LcmResponseStatus copiedStatus = new LcmResponseStatus(); + copiedStatus.setCode(status.getCode()); + copiedStatus.setMessage(status.getMessage()); + + assertTrue(status.equals(status)); + assertTrue(status.equals(copiedStatus)); + assertFalse(status.equals(null)); + assertFalse(status.equals("Hello")); + + status.setCode(-1); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setCode(-1); + assertTrue(status.equals(copiedStatus)); + status.setCode(1234); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setCode(1234); + assertTrue(status.equals(copiedStatus)); + + status.setMessage(null); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setMessage(null); + assertTrue(status.equals(copiedStatus)); + status.setMessage("The wonderful land of Oz"); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setMessage("The wonderful land of Oz"); + assertTrue(status.equals(copiedStatus)); + } +} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java new file mode 100644 index 000000000..2fc04794e --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmResponseWrapperTest.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class LcmResponseWrapperTest { + + @Test + public void testLcmResponseWrapperWrapper() { + LcmResponseWrapper responseWrapper = new LcmResponseWrapper(); + assertNotNull(responseWrapper); + assertNotEquals(0, responseWrapper.hashCode()); + + LcmResponse response = new LcmResponse(); + + responseWrapper.setBody(response); + assertEquals(response, responseWrapper.getBody()); + + assertNotEquals(0, responseWrapper.hashCode()); + + assertEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46)); + + LcmResponseWrapper copiedLcmResponseWrapper = new LcmResponseWrapper(); + copiedLcmResponseWrapper.setBody(responseWrapper.getBody()); + + assertTrue(responseWrapper.equals(responseWrapper)); + assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); + assertFalse(responseWrapper.equals(null)); + assertFalse(responseWrapper.equals("Hello")); + + responseWrapper.setBody(null); + assertFalse(responseWrapper.equals(copiedLcmResponseWrapper)); + copiedLcmResponseWrapper.setBody(null); + assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); + responseWrapper.setBody(response); + assertFalse(responseWrapper.equals(copiedLcmResponseWrapper)); + copiedLcmResponseWrapper.setBody(response); + assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); + } +} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java new file mode 100644 index 000000000..a12b7f775 --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/LcmWrapperTest.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class LcmWrapperTest { + + @Test + public void testLcmWrapper() { + LcmWrapper wrapper = new LcmWrapper(); + assertNotNull(wrapper); + assertNotEquals(0, wrapper.hashCode()); + + wrapper.setVersion("19.3.9"); + assertEquals("19.3.9", wrapper.getVersion()); + + wrapper.setCambriaPartition("The Emerald City"); + assertEquals("The Emerald City", wrapper.getCambriaPartition()); + + wrapper.setRpcName("Tornado"); + assertEquals("Tornado", wrapper.getRpcName()); + + wrapper.setCorrelationId("YellowBrickRoad"); + assertEquals("YellowBrickRoad", wrapper.getCorrelationId()); + + wrapper.setType("Munchkin"); + assertEquals("Munchkin", wrapper.getType()); + + assertNotEquals(0, wrapper.hashCode()); + + assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46)); + + LcmWrapper copiedLcmWrapper = new LcmWrapper(); + copiedLcmWrapper.setVersion(wrapper.getVersion()); + copiedLcmWrapper.setCambriaPartition(wrapper.getCambriaPartition()); + copiedLcmWrapper.setRpcName(wrapper.getRpcName()); + copiedLcmWrapper.setCorrelationId(wrapper.getCorrelationId()); + copiedLcmWrapper.setType(wrapper.getType()); + + assertTrue(wrapper.equals(wrapper)); + assertTrue(wrapper.equals(copiedLcmWrapper)); + assertFalse(wrapper.equals(null)); + assertFalse(wrapper.equals("Hello")); + + wrapper.setVersion(null); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setVersion(null); + assertTrue(wrapper.equals(copiedLcmWrapper)); + wrapper.setVersion("19.3.9"); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setVersion("19.3.9"); + assertTrue(wrapper.equals(copiedLcmWrapper)); + + wrapper.setCambriaPartition(null); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setCambriaPartition(null); + assertTrue(wrapper.equals(copiedLcmWrapper)); + wrapper.setCambriaPartition("The Emerald City"); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setCambriaPartition("The Emerald City"); + assertTrue(wrapper.equals(copiedLcmWrapper)); + + wrapper.setRpcName(null); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setRpcName(null); + assertTrue(wrapper.equals(copiedLcmWrapper)); + wrapper.setRpcName("Tornado"); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setRpcName("Tornado"); + assertTrue(wrapper.equals(copiedLcmWrapper)); + + wrapper.setCorrelationId(null); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setCorrelationId(null); + assertTrue(wrapper.equals(copiedLcmWrapper)); + wrapper.setCorrelationId("YellowBrickRoad"); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setCorrelationId("YellowBrickRoad"); + assertTrue(wrapper.equals(copiedLcmWrapper)); + + wrapper.setType(null); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setType(null); + assertTrue(wrapper.equals(copiedLcmWrapper)); + wrapper.setType("Munchkin"); + assertFalse(wrapper.equals(copiedLcmWrapper)); + copiedLcmWrapper.setType("Munchkin"); + assertTrue(wrapper.equals(copiedLcmWrapper)); + } +} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java deleted file mode 100644 index 49cc7f7de..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmCommonHeader.java +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; - -public class TestLcmCommonHeader { - - @Test - public void testLcmCommonHeader() { - LcmCommonHeader commonHeader = new LcmCommonHeader(); - assertNotNull(commonHeader); - assertNotNull(new LcmCommonHeader(commonHeader)); - assertNotEquals(0, commonHeader.hashCode()); - - commonHeader.setApiVer("Kansas"); - assertEquals("Kansas", commonHeader.getApiVer()); - - Map flagMap = new HashMap<>(); - commonHeader.setFlags(flagMap); - assertEquals(flagMap, commonHeader.getFlags()); - - commonHeader.setOriginatorId("Dorothy"); - assertEquals("Dorothy", commonHeader.getOriginatorId()); - - UUID requestId = UUID.randomUUID(); - commonHeader.setRequestId(requestId); - assertEquals(requestId, commonHeader.getRequestId()); - - commonHeader.setSubRequestId("Can I go home?"); - assertEquals("Can I go home?", commonHeader.getSubRequestId()); - - Instant timestamp = Instant.now(); - commonHeader.setTimeStamp(timestamp); - assertEquals(timestamp, commonHeader.getTimeStamp()); - - assertNotEquals(0, commonHeader.hashCode()); - - assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24)); - - LcmCommonHeader copiedLcmCommonHeader = new LcmCommonHeader(); - copiedLcmCommonHeader.setApiVer(commonHeader.getApiVer()); - copiedLcmCommonHeader.setFlags(commonHeader.getFlags()); - copiedLcmCommonHeader.setOriginatorId(commonHeader.getOriginatorId()); - copiedLcmCommonHeader.setRequestId(commonHeader.getRequestId()); - copiedLcmCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); - copiedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); - - LcmCommonHeader clonedLcmCommonHeader = new LcmCommonHeader(commonHeader); - clonedLcmCommonHeader.setApiVer(commonHeader.getApiVer()); - clonedLcmCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(clonedLcmCommonHeader)); - - commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setApiVer("Kansas"); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setApiVer("Kansas"); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setFlags(flagMap); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setFlags(flagMap); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setOriginatorId(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setOriginatorId(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setOriginatorId("Dorothy"); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setOriginatorId("Dorothy"); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setSubRequestId("Can I go home?"); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setSubRequestId("Can I go home?"); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - - commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedLcmCommonHeader)); - copiedLcmCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedLcmCommonHeader)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java deleted file mode 100644 index ce8b0415e..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequest.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -public class TestLcmRequest { - - @Test - public void testLcmRequest() { - LcmRequest request = new LcmRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - LcmCommonHeader commonHeader = new LcmCommonHeader(); - - request.setCommonHeader(commonHeader); - assertEquals(commonHeader, request.getCommonHeader()); - - request.setAction("Go to Oz"); - assertEquals("Go to Oz", request.getAction()); - - Map actionIdentifiers = new HashMap<>(); - actionIdentifiers.put("North", "Good Witch"); - actionIdentifiers.put("West", "Bad Witch"); - - request.setActionIdentifiers(actionIdentifiers); - assertEquals(actionIdentifiers, request.getActionIdentifiers()); - - request.setPayload("The Emerald City"); - assertEquals("The Emerald City", request.getPayload()); - - assertNotEquals(0, request.hashCode()); - - assertEquals("Request [commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 46)); - - LcmRequest copiedLcmRequest = new LcmRequest(); - copiedLcmRequest.setCommonHeader(request.getCommonHeader()); - copiedLcmRequest.setAction(request.getAction()); - copiedLcmRequest.setActionIdentifiers(request.getActionIdentifiers()); - copiedLcmRequest.setPayload(request.getPayload()); - - assertTrue(request.equals(request)); - assertTrue(request.equals(copiedLcmRequest)); - assertFalse(request.equals(null)); - assertFalse(request.equals("Hello")); - - request.setCommonHeader(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setCommonHeader(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setCommonHeader(commonHeader); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setCommonHeader(commonHeader); - assertTrue(request.equals(copiedLcmRequest)); - - request.setAction(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setAction(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setAction("Go to Oz"); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setAction("Go to Oz"); - assertTrue(request.equals(copiedLcmRequest)); - - request.setActionIdentifiers(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setActionIdentifiers(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setActionIdentifiers(actionIdentifiers); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setActionIdentifiers(actionIdentifiers); - assertTrue(request.equals(copiedLcmRequest)); - - request.setPayload(null); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setPayload(null); - assertTrue(request.equals(copiedLcmRequest)); - request.setPayload("The Emerald City"); - assertFalse(request.equals(copiedLcmRequest)); - copiedLcmRequest.setPayload("The Emerald City"); - assertTrue(request.equals(copiedLcmRequest)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java deleted file mode 100644 index 0f1b85a33..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmRequestWrapper.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestLcmRequestWrapper { - - @Test - public void testLcmRequestWrapperWrapper() { - assertNotNull(new LcmRequestWrapper(new LcmRequest())); - LcmRequestWrapper requestWrapper = new LcmRequestWrapper(); - assertNotNull(requestWrapper); - assertNotEquals(0, requestWrapper.hashCode()); - - LcmRequest request = new LcmRequest(); - - requestWrapper.setBody(request); - assertEquals(request, requestWrapper.getBody()); - - assertNotEquals(0, requestWrapper.hashCode()); - - assertEquals("RequestWrapper [body=Request [commonHeader=nul", requestWrapper.toString().substring(0, 46)); - - LcmRequestWrapper copiedLcmRequestWrapper = new LcmRequestWrapper(); - copiedLcmRequestWrapper.setBody(requestWrapper.getBody()); - - assertTrue(requestWrapper.equals(requestWrapper)); - assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); - assertFalse(requestWrapper.equals(null)); - assertFalse(requestWrapper.equals("Hello")); - - requestWrapper.setBody(null); - assertFalse(requestWrapper.equals(copiedLcmRequestWrapper)); - copiedLcmRequestWrapper.setBody(null); - assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); - requestWrapper.setBody(request); - assertFalse(requestWrapper.equals(copiedLcmRequestWrapper)); - copiedLcmRequestWrapper.setBody(request); - assertTrue(requestWrapper.equals(copiedLcmRequestWrapper)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java deleted file mode 100644 index cf42845cc..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResonseCode.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class TestLcmResonseCode { - - @Test - public void testLcmResponseCode() { - assertNull(LcmResponseCode.toResponseValue(0)); - - assertEquals(LcmResponseCode.ACCEPTED, LcmResponseCode.toResponseValue(100)); - assertEquals(LcmResponseCode.ERROR, LcmResponseCode.toResponseValue(200)); - assertEquals(LcmResponseCode.REJECT, LcmResponseCode.toResponseValue(300)); - assertEquals(LcmResponseCode.SUCCESS, LcmResponseCode.toResponseValue(400)); - assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(450)); - assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(401)); - assertEquals(LcmResponseCode.FAILURE, LcmResponseCode.toResponseValue(406)); - assertEquals(LcmResponseCode.PARTIAL_SUCCESS, LcmResponseCode.toResponseValue(500)); - assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(501)); - assertEquals(LcmResponseCode.PARTIAL_FAILURE, LcmResponseCode.toResponseValue(599)); - - assertEquals("100", new LcmResponseCode(100).toString()); - assertEquals("200", new LcmResponseCode(200).toString()); - assertEquals("300", new LcmResponseCode(300).toString()); - assertEquals("400", new LcmResponseCode(400).toString()); - assertEquals("450", new LcmResponseCode(450).toString()); - assertEquals("500", new LcmResponseCode(500).toString()); - assertEquals("510", new LcmResponseCode(510).toString()); - - assertEquals(300, new LcmResponseCode(300).getCode()); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.java deleted file mode 100644 index b5d4cf3a5..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseStatus.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestLcmResponseStatus { - - @Test - public void testResonseStatus() { - LcmResponseStatus status = new LcmResponseStatus(); - assertNotNull(status); - assertNotEquals(0, status.hashCode()); - - status.setCode(1234); - assertEquals(1234, status.getCode()); - - status.setMessage("The wonderful land of Oz"); - assertEquals("The wonderful land of Oz", status.getMessage()); - - assertEquals("ResponseStatus [code=1234, message=The wonderfu", status.toString().substring(0, 47)); - - LcmResponseStatus copiedStatus = new LcmResponseStatus(); - copiedStatus.setCode(status.getCode()); - copiedStatus.setMessage(status.getMessage()); - - assertTrue(status.equals(status)); - assertTrue(status.equals(copiedStatus)); - assertFalse(status.equals(null)); - assertFalse(status.equals("Hello")); - - status.setCode(-1); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(-1); - assertTrue(status.equals(copiedStatus)); - status.setCode(1234); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(1234); - assertTrue(status.equals(copiedStatus)); - - status.setMessage(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setMessage(null); - assertTrue(status.equals(copiedStatus)); - status.setMessage("The wonderful land of Oz"); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setMessage("The wonderful land of Oz"); - assertTrue(status.equals(copiedStatus)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java deleted file mode 100644 index bf448534f..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmResponseWrapper.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestLcmResponseWrapper { - - @Test - public void testLcmResponseWrapperWrapper() { - LcmResponseWrapper responseWrapper = new LcmResponseWrapper(); - assertNotNull(responseWrapper); - assertNotEquals(0, responseWrapper.hashCode()); - - LcmResponse response = new LcmResponse(); - - responseWrapper.setBody(response); - assertEquals(response, responseWrapper.getBody()); - - assertNotEquals(0, responseWrapper.hashCode()); - - assertEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46)); - - LcmResponseWrapper copiedLcmResponseWrapper = new LcmResponseWrapper(); - copiedLcmResponseWrapper.setBody(responseWrapper.getBody()); - - assertTrue(responseWrapper.equals(responseWrapper)); - assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("Hello")); - - responseWrapper.setBody(null); - assertFalse(responseWrapper.equals(copiedLcmResponseWrapper)); - copiedLcmResponseWrapper.setBody(null); - assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); - responseWrapper.setBody(response); - assertFalse(responseWrapper.equals(copiedLcmResponseWrapper)); - copiedLcmResponseWrapper.setBody(response); - assertTrue(responseWrapper.equals(copiedLcmResponseWrapper)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java deleted file mode 100644 index d14cb4b24..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/TestLcmWrapper.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appclcm; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestLcmWrapper { - - @Test - public void testLcmWrapper() { - LcmWrapper wrapper = new LcmWrapper(); - assertNotNull(wrapper); - assertNotEquals(0, wrapper.hashCode()); - - wrapper.setVersion("19.3.9"); - assertEquals("19.3.9", wrapper.getVersion()); - - wrapper.setCambriaPartition("The Emerald City"); - assertEquals("The Emerald City", wrapper.getCambriaPartition()); - - wrapper.setRpcName("Tornado"); - assertEquals("Tornado", wrapper.getRpcName()); - - wrapper.setCorrelationId("YellowBrickRoad"); - assertEquals("YellowBrickRoad", wrapper.getCorrelationId()); - - wrapper.setType("Munchkin"); - assertEquals("Munchkin", wrapper.getType()); - - assertNotEquals(0, wrapper.hashCode()); - - assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46)); - - LcmWrapper copiedLcmWrapper = new LcmWrapper(); - copiedLcmWrapper.setVersion(wrapper.getVersion()); - copiedLcmWrapper.setCambriaPartition(wrapper.getCambriaPartition()); - copiedLcmWrapper.setRpcName(wrapper.getRpcName()); - copiedLcmWrapper.setCorrelationId(wrapper.getCorrelationId()); - copiedLcmWrapper.setType(wrapper.getType()); - - assertTrue(wrapper.equals(wrapper)); - assertTrue(wrapper.equals(copiedLcmWrapper)); - assertFalse(wrapper.equals(null)); - assertFalse(wrapper.equals("Hello")); - - wrapper.setVersion(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setVersion(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setVersion("19.3.9"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setVersion("19.3.9"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setCambriaPartition(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCambriaPartition(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setCambriaPartition("The Emerald City"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCambriaPartition("The Emerald City"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setRpcName(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setRpcName(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setRpcName("Tornado"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setRpcName("Tornado"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setCorrelationId(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCorrelationId(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setCorrelationId("YellowBrickRoad"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setCorrelationId("YellowBrickRoad"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - - wrapper.setType(null); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setType(null); - assertTrue(wrapper.equals(copiedLcmWrapper)); - wrapper.setType("Munchkin"); - assertFalse(wrapper.equals(copiedLcmWrapper)); - copiedLcmWrapper.setType("Munchkin"); - assertTrue(wrapper.equals(copiedLcmWrapper)); - } -} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java new file mode 100644 index 000000000..62f98644f --- /dev/null +++ b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/SerializationTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * appc + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.appclcm.util; + +import static org.junit.Assert.assertEquals; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +import org.junit.Test; + +public class SerializationTest { + + @Test + public void test() { + String nameString = "Dorothy"; + String jsonName = Serialization.gsonPretty.toJson(nameString, String.class); + assertEquals("\"Dorothy\"", jsonName); + String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class); + assertEquals("Dorothy", jsonInOutName); + + Instant instant0 = Instant.ofEpochMilli(1516127215000L); + String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class); + assertEquals("\"2018-01-16T18:26:55Z\"", instantString0); + Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class); + assertEquals(instant0, outInstant0); + + Instant instant1 = Instant.ofEpochMilli(1516127215000L); + String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class); + assertEquals("1516127215000", instantString1); + Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class); + assertEquals(instant1, outInstant1); + + ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC")); + String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class); + assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29)); + } +} diff --git a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java b/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java deleted file mode 100644 index 4e403ecb4..000000000 --- a/controlloop/common/model-impl/appclcm/src/test/java/org/onap/policy/appclcm/util/TestSerialization.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * appc - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.appclcm.util; - -import static org.junit.Assert.assertEquals; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; - -import org.junit.Test; - -public class TestSerialization { - - @Test - public void test() { - String nameString = "Dorothy"; - String jsonName = Serialization.gsonPretty.toJson(nameString, String.class); - assertEquals("\"Dorothy\"", jsonName); - String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class); - assertEquals("Dorothy", jsonInOutName); - - Instant instant0 = Instant.ofEpochMilli(1516127215000L); - String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class); - assertEquals("\"2018-01-16T18:26:55Z\"", instantString0); - Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class); - assertEquals(instant0, outInstant0); - - Instant instant1 = Instant.ofEpochMilli(1516127215000L); - String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class); - assertEquals("1516127215000", instantString1); - Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class); - assertEquals(instant1, outInstant1); - - ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC")); - String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class); - assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29)); - } -} diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java new file mode 100755 index 000000000..11366c6a0 --- /dev/null +++ b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/GetTest.java @@ -0,0 +1,66 @@ +/* + * ============LICENSE_START======================================================= + * rest + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.rest; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.onap.policy.rest.RESTManager.Pair; + +public class GetTest { + + @Test(expected = NullPointerException.class) + public void testUrlNull() { + RESTManager mgr = new RESTManager(); + mgr.get(null, "user", null, null); + } + + @Test + public void testUsernameNull() { + RESTManager mgr = new RESTManager(); + + Pair result = mgr.get("http://www.example.org", null, null, null); + assertEquals((Integer)200, result.first); + assertTrue(result.second != null); + assertTrue(result.second.length() > 0); + } + + @Test + public void testUsernameEmpty() { + RESTManager mgr = new RESTManager(); + + Pair result = mgr.get("http://www.example.org", "", null, null); + assertEquals((Integer)200, result.first); + assertTrue(result.second != null); + assertTrue(result.second.length() > 0); + } + + @Test + public void testUrlExampleOrg() { + RESTManager mgr = new RESTManager(); + + Pair result = mgr.get("http://www.example.org", "user", null, null); + assertEquals((Integer)200, result.first); + assertTrue(result.second != null); + assertTrue(result.second.length() > 0); + } +} \ No newline at end of file diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PairTest.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PairTest.java new file mode 100755 index 000000000..e245eabdb --- /dev/null +++ b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PairTest.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * rest + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.rest; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.policy.rest.RESTManager.Pair; + +public class PairTest { + + @Test + public void testPair() { + RESTManager mgr = new RESTManager(); + + Pair pii = mgr.new Pair<>(1, 2); + assertEquals((Integer) 1, (Integer) pii.first); + assertEquals((Integer) 2, (Integer) pii.second); + + Pair pis = mgr.new Pair<>(1, "test"); + assertEquals((Integer) 1, (Integer) pis.first); + assertEquals("test", pis.second); + } +} diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java new file mode 100755 index 000000000..aedd0b288 --- /dev/null +++ b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/PostTest.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * rest + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.rest; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.policy.rest.RESTManager.Pair; + +public class PostTest { + + @Test + public void testUsernameNull() { + RESTManager mgr = new RESTManager(); + Pair result = mgr.post("http://www.example.org", null, null, null, null, null); + assertEquals(null, result); + } + + @Test + public void testUsernameEmpty() { + RESTManager mgr = new RESTManager(); + Pair result = mgr.post("http://www.example.org", "", null, null, null, null); + assertEquals(null, result); + } + + @Test + public void testBodyNull() { + RESTManager mgr = new RESTManager(); + Pair result = mgr.post("http://www.example.org", "user", null, null, null, null); + assertEquals(null, result); + } +} diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java deleted file mode 100755 index 7e881df51..000000000 --- a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestGet.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * rest - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.rest; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.onap.policy.rest.RESTManager.Pair; - -public class TestGet { - - @Test(expected = NullPointerException.class) - public void testUrlNull() { - RESTManager mgr = new RESTManager(); - mgr.get(null, "user", null, null); - } - - @Test - public void testUsernameNull() { - RESTManager mgr = new RESTManager(); - - Pair result = mgr.get("http://www.example.org", null, null, null); - assertEquals((Integer)200, result.first); - assertTrue(result.second != null); - assertTrue(result.second.length() > 0); - } - - @Test - public void testUsernameEmpty() { - RESTManager mgr = new RESTManager(); - - Pair result = mgr.get("http://www.example.org", "", null, null); - assertEquals((Integer)200, result.first); - assertTrue(result.second != null); - assertTrue(result.second.length() > 0); - } - - @Test - public void testUrlExampleOrg() { - RESTManager mgr = new RESTManager(); - - Pair result = mgr.get("http://www.example.org", "user", null, null); - assertEquals((Integer)200, result.first); - assertTrue(result.second != null); - assertTrue(result.second.length() > 0); - } -} \ No newline at end of file diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPair.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPair.java deleted file mode 100755 index 28e9934d1..000000000 --- a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPair.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * rest - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.rest; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.policy.rest.RESTManager.Pair; - -public class TestPair { - - @Test - public void testPair() { - RESTManager mgr = new RESTManager(); - - Pair pii = mgr.new Pair<>(1, 2); - assertEquals((Integer) 1, (Integer) pii.first); - assertEquals((Integer) 2, (Integer) pii.second); - - Pair pis = mgr.new Pair<>(1, "test"); - assertEquals((Integer) 1, (Integer) pis.first); - assertEquals("test", pis.second); - } -} diff --git a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java b/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java deleted file mode 100755 index 58ba5d247..000000000 --- a/controlloop/common/model-impl/rest/src/test/java/org/onap/policy/rest/TestPost.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * rest - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.rest; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.onap.policy.rest.RESTManager.Pair; - -public class TestPost { - - @Test - public void testUsernameNull() { - RESTManager mgr = new RESTManager(); - Pair result = mgr.post("http://www.example.org", null, null, null, null, null); - assertEquals(null, result); - } - - @Test - public void testUsernameEmpty() { - RESTManager mgr = new RESTManager(); - Pair result = mgr.post("http://www.example.org", "", null, null, null, null); - assertEquals(null, result); - } - - @Test - public void testBodyNull() { - RESTManager mgr = new RESTManager(); - Pair result = mgr.post("http://www.example.org", "user", null, null, null, null); - assertEquals(null, result); - } -} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java new file mode 100644 index 000000000..572a1186a --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceInstanceTest.java @@ -0,0 +1,155 @@ +/*- + * ============LICENSE_START======================================================= + * sdc + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.UUID; + +import org.junit.Test; + +public class ResourceInstanceTest { + + @Test + public void testConstructors() { + ResourceInstance ri = new ResourceInstance(); + assertEquals(null, ri.getResourceInstanceName()); + assertEquals(null, ri.getResourceUuid()); + assertEquals(null, ri.getResourceInvariantUUID()); + assertEquals(null, ri.getResourceName()); + assertEquals(null, ri.getResourceType()); + assertEquals(null, ri.getResourceVersion()); + + ResourceInstance ri2 = new ResourceInstance((ResourceInstance) null); + assertEquals(null, ri2.getResourceInstanceName()); + assertEquals(null, ri2.getResourceUuid()); + assertEquals(null, ri2.getResourceInvariantUUID()); + assertEquals(null, ri2.getResourceName()); + assertEquals(null, ri2.getResourceType()); + assertEquals(null, ri2.getResourceVersion()); + + ri2 = new ResourceInstance(ri); + assertEquals(ri2.getResourceInstanceName(), ri.getResourceInstanceName()); + assertEquals(ri2.getResourceUuid(), ri.getResourceUuid()); + assertEquals(ri2.getResourceInvariantUUID(), ri.getResourceInvariantUUID()); + assertEquals(ri2.getResourceName(), ri.getResourceName()); + assertEquals(ri2.getResourceType(), ri.getResourceType()); + assertEquals(ri2.getResourceVersion(), ri.getResourceVersion()); + } + + @Test + public void testInstanceName() { + ResourceInstance ri = new ResourceInstance(); + String name = "nameTestInstance"; + ri.setResourceInstanceName(name);; + assertEquals(name, ri.getResourceInstanceName()); + } + + @Test + public void testUuid() { + ResourceInstance ri = new ResourceInstance(); + UUID uuid = UUID.randomUUID(); + ri.setResourceUuid(uuid); + assertEquals(uuid, ri.getResourceUuid()); + } + + @Test + public void testInvariantUuid() { + ResourceInstance ri = new ResourceInstance(); + UUID uuid = UUID.randomUUID(); + ri.setResourceInvariantUUID(uuid); + assertEquals(uuid, ri.getResourceInvariantUUID()); + } + + @Test + public void testName() { + ResourceInstance ri = new ResourceInstance(); + String name = "nameTest"; + ri.setResourceName(name); + assertEquals(name, ri.getResourceName()); + } + + @Test + public void testVersion() { + ResourceInstance ri = new ResourceInstance(); + String version = "versionTest"; + ri.setResourceVersion(version); + assertEquals(version, ri.getResourceVersion()); + } + + @Test + public void testType() { + ResourceInstance ri = new ResourceInstance(); + ri.setResourceType(ResourceType.CP); + assertEquals(ResourceType.CP, ri.getResourceType()); + } + + @Test + public void testEquals() { + ResourceInstance ri1 = new ResourceInstance(); + ResourceInstance ri2 = new ResourceInstance(ri1); + assertTrue(ri1.equals(ri2)); + assertTrue(ri2.equals(ri1)); + + ri1.setResourceInstanceName("instance"); + ri1.setResourceName("resource"); + ri1.setResourceInvariantUUID(UUID.randomUUID()); + ri1.setResourceInvariantUUID(UUID.randomUUID()); + ri1.setResourceVersion("0.0.0"); + ri1.setResourceType(ResourceType.VL); + ri2 = new ResourceInstance(ri1); + assertTrue(ri1.equals(ri2)); + assertTrue(ri2.equals(ri1)); + } + + @Test + public void testToString() { + ResourceInstance ri1 = new ResourceInstance(); + ResourceInstance ri2 = new ResourceInstance(ri1); + assertEquals(ri1.toString(), ri2.toString()); + + ri1.setResourceInstanceName("instance"); + ri1.setResourceName("resource"); + ri1.setResourceInvariantUUID(UUID.randomUUID()); + ri1.setResourceInvariantUUID(UUID.randomUUID()); + ri1.setResourceVersion("0.0.0"); + ri1.setResourceType(ResourceType.VL); + ri2 = new ResourceInstance(ri1); + assertEquals(ri1.toString(), ri2.toString()); + } + + @Test + public void testHashCode() { + ResourceInstance ri1 = new ResourceInstance(); + ResourceInstance ri2 = new ResourceInstance(ri1); + assertEquals(ri1.hashCode(), ri2.hashCode()); + + ri1.setResourceInstanceName("instance"); + ri1.setResourceName("resource"); + ri1.setResourceInvariantUUID(UUID.randomUUID()); + ri1.setResourceInvariantUUID(UUID.randomUUID()); + ri1.setResourceVersion("0.0.0"); + ri1.setResourceType(ResourceType.VL); + ri2 = new ResourceInstance(ri1); + assertEquals(ri1.hashCode(), ri2.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java new file mode 100644 index 000000000..0ee68a11e --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ResourceTest.java @@ -0,0 +1,152 @@ +/*- + * ============LICENSE_START======================================================= + * sdc + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.UUID; + +import org.junit.Test; + +public class ResourceTest { + + @Test + public void testConstructors() { + Resource res = new Resource(); + assertEquals(null, res.getResourceUuid()); + assertEquals(null, res.getResourceInvariantUuid()); + assertEquals(null, res.getResourceName()); + assertEquals(null, res.getResourceType()); + assertEquals(null, res.getResourceVersion()); + + UUID uuid = UUID.randomUUID(); + res = new Resource(uuid); + assertEquals(uuid, res.getResourceUuid()); + assertEquals(null, res.getResourceInvariantUuid()); + assertEquals(null, res.getResourceName()); + assertEquals(null, res.getResourceType()); + assertEquals(null, res.getResourceVersion()); + + String name = "constTest"; + res = new Resource(name, ResourceType.CP); + assertEquals(null, res.getResourceUuid()); + assertEquals(name, res.getResourceName()); + assertEquals(ResourceType.CP, res.getResourceType()); + assertEquals(null, res.getResourceInvariantUuid()); + assertEquals(null, res.getResourceVersion()); + + uuid = UUID.randomUUID(); + UUID uuidInvariant = UUID.randomUUID(); + name = "constTestUUID"; + String version = "0.0.1"; + res = new Resource(uuid, uuidInvariant, name, version, ResourceType.VF); + assertEquals(uuid, res.getResourceUuid()); + assertEquals(uuidInvariant, res.getResourceInvariantUuid()); + assertEquals(name, res.getResourceName()); + assertEquals(ResourceType.VF, res.getResourceType()); + assertEquals(version, res.getResourceVersion()); + + Resource r2 = new Resource(res); + assertEquals(uuid, r2.getResourceUuid()); + assertEquals(uuidInvariant, r2.getResourceInvariantUuid()); + assertEquals(name, r2.getResourceName()); + assertEquals(ResourceType.VF, r2.getResourceType()); + assertEquals(version, r2.getResourceVersion()); + } + + @Test + public void testUuid() { + Resource res = new Resource(); + UUID uuid = UUID.randomUUID(); + res.setResourceUuid(uuid); + assertEquals(uuid, res.getResourceUuid()); + } + + @Test + public void testInvariantUuid() { + Resource res = new Resource(); + UUID uuid = UUID.randomUUID(); + res.setResourceInvariantUuid(uuid); + assertEquals(uuid, res.getResourceInvariantUuid()); + } + + @Test + public void testName() { + Resource res = new Resource(); + String name = "nameTest"; + res.setResourceName(name); + assertEquals(name, res.getResourceName()); + } + + @Test + public void testVersion() { + Resource res = new Resource(); + String version = "versionTest"; + res.setResourceVersion(version); + assertEquals(version, res.getResourceVersion()); + } + + @Test + public void testType() { + Resource res = new Resource(); + res.setResourceType(ResourceType.CP); + assertEquals(ResourceType.CP, res.getResourceType()); + } + + @Test + public void testEquals() { + Resource r1 = new Resource(); + Resource r2 = new Resource(r1); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1", + ResourceType.VFC); + r2 = new Resource(r1); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + } + + @Test + public void testToString() { + Resource r1 = new Resource(); + Resource r2 = new Resource(r1); + assertEquals(r1.toString(), r2.toString()); + + r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1", + ResourceType.VFC); + r2 = new Resource(r1); + assertEquals(r1.toString(), r2.toString()); + } + + @Test + public void testHashCode() { + Resource r1 = new Resource(); + Resource r2 = new Resource(r1); + assertEquals(r1.hashCode(), r2.hashCode()); + + r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1", + ResourceType.VFC); + r2 = new Resource(r1); + assertEquals(r1.hashCode(), r2.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java new file mode 100644 index 000000000..14f2d3d37 --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceInstanceTest.java @@ -0,0 +1,170 @@ +/*- + * ============LICENSE_START======================================================= + * sdc + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.UUID; + +import org.junit.Test; + +public class ServiceInstanceTest { + + @Test + public void testConstructors() { + ServiceInstance si = new ServiceInstance(); + assertEquals(null, si.getServiceInstanceName()); + assertEquals(null, si.getServiceUUID()); + assertEquals(null, si.getServiceInstanceUUID()); + assertEquals(null, si.getServiceName()); + assertEquals(null, si.getPersonaModelUUID()); + assertEquals(null, si.getWidgetModelUUID()); + assertEquals(null, si.getWidgetModelVersion()); + + ServiceInstance si2 = new ServiceInstance((ServiceInstance) null); + assertEquals(null, si2.getServiceInstanceName()); + assertEquals(null, si2.getServiceUUID()); + assertEquals(null, si2.getServiceInstanceUUID()); + assertEquals(null, si2.getServiceName()); + assertEquals(null, si2.getPersonaModelUUID()); + assertEquals(null, si2.getWidgetModelUUID()); + assertEquals(null, si2.getWidgetModelVersion()); + + si2 = new ServiceInstance(si); + assertEquals(si2.getServiceInstanceName(), si.getServiceInstanceName()); + assertEquals(si2.getServiceUUID(), si.getServiceUUID()); + assertEquals(si2.getServiceInstanceUUID(), si.getServiceInstanceUUID()); + assertEquals(si2.getServiceName(), si.getServiceName()); + assertEquals(si2.getPersonaModelUUID(), si.getPersonaModelUUID()); + assertEquals(si2.getWidgetModelUUID(), si.getWidgetModelUUID()); + assertEquals(si2.getWidgetModelVersion(), si.getWidgetModelVersion()); + } + + @Test + public void testInstanceName() { + ServiceInstance si = new ServiceInstance(); + String name = "nameTestInstance"; + si.setServiceInstanceName(name);; + assertEquals(name, si.getServiceInstanceName()); + } + + @Test + public void testUuid() { + ServiceInstance si = new ServiceInstance(); + UUID uuid = UUID.randomUUID(); + si.setServiceUUID(uuid); + assertEquals(uuid, si.getServiceUUID()); + } + + @Test + public void testInstanceUuid() { + ServiceInstance si = new ServiceInstance(); + UUID uuid = UUID.randomUUID(); + si.setServiceInstanceUUID(uuid); + assertEquals(uuid, si.getServiceInstanceUUID()); + } + + @Test + public void testName() { + ServiceInstance si = new ServiceInstance(); + String name = "nameTest"; + si.setServiceName(name); + assertEquals(name, si.getServiceName()); + } + + @Test + public void testPersonaModelUuid() { + ServiceInstance si = new ServiceInstance(); + UUID uuid = UUID.randomUUID(); + si.setPersonaModelUUID(uuid); + assertEquals(uuid, si.getPersonaModelUUID()); + } + + @Test + public void testWidgetModelUuid() { + ServiceInstance si = new ServiceInstance(); + UUID uuid = UUID.randomUUID(); + si.setWidgetModelUUID(uuid); + assertEquals(uuid, si.getWidgetModelUUID()); + } + + @Test + public void testWidgetModelVersion() { + ServiceInstance si = new ServiceInstance(); + String version = "2.2.2"; + si.setWidgetModelVersion(version);; + assertEquals(version, si.getWidgetModelVersion()); + } + + @Test + public void testEquals() { + ServiceInstance si1 = new ServiceInstance(); + ServiceInstance si2 = new ServiceInstance(si1); + assertTrue(si1.equals(si2)); + assertTrue(si2.equals(si1)); + + si1.setServiceInstanceName("instance"); + si1.setServiceName("service"); + si1.setServiceInstanceUUID(UUID.randomUUID()); + si1.setServiceUUID(UUID.randomUUID()); + si1.setPersonaModelUUID(UUID.randomUUID()); + si1.setWidgetModelUUID(UUID.randomUUID()); + si1.setWidgetModelVersion("3.3.3"); + si2 = new ServiceInstance(si1); + assertTrue(si1.equals(si2)); + assertTrue(si2.equals(si1)); + } + + @Test + public void testToString() { + ServiceInstance si1 = new ServiceInstance(); + ServiceInstance si2 = new ServiceInstance(si1); + assertEquals(si1.toString(), si2.toString()); + + si1.setServiceInstanceName("instance"); + si1.setServiceName("service"); + si1.setServiceInstanceUUID(UUID.randomUUID()); + si1.setServiceUUID(UUID.randomUUID()); + si1.setPersonaModelUUID(UUID.randomUUID()); + si1.setWidgetModelUUID(UUID.randomUUID()); + si1.setWidgetModelVersion("3.3.3"); + si2 = new ServiceInstance(si1); + assertEquals(si1.toString(), si2.toString()); + } + + @Test + public void testHashCode() { + ServiceInstance si1 = new ServiceInstance(); + ServiceInstance si2 = new ServiceInstance(si1); + assertEquals(si1.hashCode(), si2.hashCode()); + + si1.setServiceInstanceName("instance"); + si1.setServiceName("service"); + si1.setServiceInstanceUUID(UUID.randomUUID()); + si1.setServiceUUID(UUID.randomUUID()); + si1.setPersonaModelUUID(UUID.randomUUID()); + si1.setWidgetModelUUID(UUID.randomUUID()); + si1.setWidgetModelVersion("3.3.3"); + si2 = new ServiceInstance(si1); + assertEquals(si1.hashCode(), si2.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java new file mode 100644 index 000000000..a7d223d18 --- /dev/null +++ b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/ServiceTest.java @@ -0,0 +1,137 @@ +/*- + * ============LICENSE_START======================================================= + * sdc + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.UUID; + +import org.junit.Test; + +public class ServiceTest { + + @Test + public void testConstructors() { + Service svc = new Service(); + assertEquals(null, svc.getServiceUUID()); + assertEquals(null, svc.getServiceInvariantUUID()); + assertEquals(null, svc.getServiceName()); + assertEquals(null, svc.getServiceVersion()); + + UUID uuid = UUID.randomUUID(); + svc = new Service(uuid); + assertEquals(uuid, svc.getServiceUUID()); + assertEquals(null, svc.getServiceInvariantUUID()); + assertEquals(null, svc.getServiceName()); + assertEquals(null, svc.getServiceVersion()); + + String name = "constTest"; + svc = new Service(name); + assertEquals(null, svc.getServiceUUID()); + assertEquals(name, svc.getServiceName()); + assertEquals(null, svc.getServiceInvariantUUID()); + assertEquals(null, svc.getServiceVersion()); + + uuid = UUID.randomUUID(); + UUID uuidInvariant = UUID.randomUUID(); + name = "constTestUUID"; + String version = "0.0.1"; + svc = new Service(uuid, uuidInvariant, name, version); + assertEquals(uuid, svc.getServiceUUID()); + assertEquals(uuidInvariant, svc.getServiceInvariantUUID()); + assertEquals(name, svc.getServiceName()); + assertEquals(version, svc.getServiceVersion()); + + Service s2 = new Service(svc); + assertEquals(uuid, s2.getServiceUUID()); + assertEquals(uuidInvariant, s2.getServiceInvariantUUID()); + assertEquals(name, s2.getServiceName()); + assertEquals(version, s2.getServiceVersion()); + } + + @Test + public void testUuid() { + Service svc = new Service(); + UUID uuid = UUID.randomUUID(); + svc.setServiceUUID(uuid); + assertEquals(uuid, svc.getServiceUUID()); + } + + @Test + public void testInvariantUuid() { + Service svc = new Service(); + UUID uuid = UUID.randomUUID(); + svc.setServiceInvariantUUID(uuid); + assertEquals(uuid, svc.getServiceInvariantUUID()); + } + + @Test + public void testName() { + Service svc = new Service(); + String name = "nameTest"; + svc.setServiceName(name); + assertEquals(name, svc.getServiceName()); + } + + @Test + public void testVersion() { + Service svc = new Service(); + String version = "versionTest"; + svc.setServiceVersion(version); + assertEquals(version, svc.getServiceVersion()); + } + + @Test + public void testEquals() { + Service s1 = new Service(); + Service s2 = new Service(s1); + assertTrue(s1.equals(s2)); + assertTrue(s2.equals(s1)); + + s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1"); + s2 = new Service(s1); + assertTrue(s1.equals(s2)); + assertTrue(s2.equals(s1)); + } + + @Test + public void testToString() { + Service s1 = new Service(); + Service s2 = new Service(s1); + assertEquals(s1.toString(), s2.toString()); + + s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1"); + s2 = new Service(s1); + assertEquals(s1.toString(), s2.toString()); + } + + @Test + public void testHashCode() { + Service s1 = new Service(); + Service s2 = new Service(s1); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1"); + s2 = new Service(s1); + assertEquals(s1.hashCode(), s2.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestResource.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestResource.java deleted file mode 100644 index 7b3a3e1f6..000000000 --- a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestResource.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.junit.Test; - -public class TestResource { - - @Test - public void testConstructors() { - Resource res = new Resource(); - assertEquals(null, res.getResourceUuid()); - assertEquals(null, res.getResourceInvariantUuid()); - assertEquals(null, res.getResourceName()); - assertEquals(null, res.getResourceType()); - assertEquals(null, res.getResourceVersion()); - - UUID uuid = UUID.randomUUID(); - res = new Resource(uuid); - assertEquals(uuid, res.getResourceUuid()); - assertEquals(null, res.getResourceInvariantUuid()); - assertEquals(null, res.getResourceName()); - assertEquals(null, res.getResourceType()); - assertEquals(null, res.getResourceVersion()); - - String name = "constTest"; - res = new Resource(name, ResourceType.CP); - assertEquals(null, res.getResourceUuid()); - assertEquals(name, res.getResourceName()); - assertEquals(ResourceType.CP, res.getResourceType()); - assertEquals(null, res.getResourceInvariantUuid()); - assertEquals(null, res.getResourceVersion()); - - uuid = UUID.randomUUID(); - UUID uuidInvariant = UUID.randomUUID(); - name = "constTestUUID"; - String version = "0.0.1"; - res = new Resource(uuid, uuidInvariant, name, version, ResourceType.VF); - assertEquals(uuid, res.getResourceUuid()); - assertEquals(uuidInvariant, res.getResourceInvariantUuid()); - assertEquals(name, res.getResourceName()); - assertEquals(ResourceType.VF, res.getResourceType()); - assertEquals(version, res.getResourceVersion()); - - Resource r2 = new Resource(res); - assertEquals(uuid, r2.getResourceUuid()); - assertEquals(uuidInvariant, r2.getResourceInvariantUuid()); - assertEquals(name, r2.getResourceName()); - assertEquals(ResourceType.VF, r2.getResourceType()); - assertEquals(version, r2.getResourceVersion()); - } - - @Test - public void testUuid() { - Resource res = new Resource(); - UUID uuid = UUID.randomUUID(); - res.setResourceUuid(uuid); - assertEquals(uuid, res.getResourceUuid()); - } - - @Test - public void testInvariantUuid() { - Resource res = new Resource(); - UUID uuid = UUID.randomUUID(); - res.setResourceInvariantUuid(uuid); - assertEquals(uuid, res.getResourceInvariantUuid()); - } - - @Test - public void testName() { - Resource res = new Resource(); - String name = "nameTest"; - res.setResourceName(name); - assertEquals(name, res.getResourceName()); - } - - @Test - public void testVersion() { - Resource res = new Resource(); - String version = "versionTest"; - res.setResourceVersion(version); - assertEquals(version, res.getResourceVersion()); - } - - @Test - public void testType() { - Resource res = new Resource(); - res.setResourceType(ResourceType.CP); - assertEquals(ResourceType.CP, res.getResourceType()); - } - - @Test - public void testEquals() { - Resource r1 = new Resource(); - Resource r2 = new Resource(r1); - assertTrue(r1.equals(r2)); - assertTrue(r2.equals(r1)); - - r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1", - ResourceType.VFC); - r2 = new Resource(r1); - assertTrue(r1.equals(r2)); - assertTrue(r2.equals(r1)); - } - - @Test - public void testToString() { - Resource r1 = new Resource(); - Resource r2 = new Resource(r1); - assertEquals(r1.toString(), r2.toString()); - - r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1", - ResourceType.VFC); - r2 = new Resource(r1); - assertEquals(r1.toString(), r2.toString()); - } - - @Test - public void testHashCode() { - Resource r1 = new Resource(); - Resource r2 = new Resource(r1); - assertEquals(r1.hashCode(), r2.hashCode()); - - r1 = new Resource(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1", - ResourceType.VFC); - r2 = new Resource(r1); - assertEquals(r1.hashCode(), r2.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestResourceInstance.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestResourceInstance.java deleted file mode 100644 index 2a1dc42b3..000000000 --- a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestResourceInstance.java +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.junit.Test; - -public class TestResourceInstance { - - @Test - public void testConstructors() { - ResourceInstance ri = new ResourceInstance(); - assertEquals(null, ri.getResourceInstanceName()); - assertEquals(null, ri.getResourceUuid()); - assertEquals(null, ri.getResourceInvariantUUID()); - assertEquals(null, ri.getResourceName()); - assertEquals(null, ri.getResourceType()); - assertEquals(null, ri.getResourceVersion()); - - ResourceInstance ri2 = new ResourceInstance((ResourceInstance) null); - assertEquals(null, ri2.getResourceInstanceName()); - assertEquals(null, ri2.getResourceUuid()); - assertEquals(null, ri2.getResourceInvariantUUID()); - assertEquals(null, ri2.getResourceName()); - assertEquals(null, ri2.getResourceType()); - assertEquals(null, ri2.getResourceVersion()); - - ri2 = new ResourceInstance(ri); - assertEquals(ri2.getResourceInstanceName(), ri.getResourceInstanceName()); - assertEquals(ri2.getResourceUuid(), ri.getResourceUuid()); - assertEquals(ri2.getResourceInvariantUUID(), ri.getResourceInvariantUUID()); - assertEquals(ri2.getResourceName(), ri.getResourceName()); - assertEquals(ri2.getResourceType(), ri.getResourceType()); - assertEquals(ri2.getResourceVersion(), ri.getResourceVersion()); - } - - @Test - public void testInstanceName() { - ResourceInstance ri = new ResourceInstance(); - String name = "nameTestInstance"; - ri.setResourceInstanceName(name);; - assertEquals(name, ri.getResourceInstanceName()); - } - - @Test - public void testUuid() { - ResourceInstance ri = new ResourceInstance(); - UUID uuid = UUID.randomUUID(); - ri.setResourceUuid(uuid); - assertEquals(uuid, ri.getResourceUuid()); - } - - @Test - public void testInvariantUuid() { - ResourceInstance ri = new ResourceInstance(); - UUID uuid = UUID.randomUUID(); - ri.setResourceInvariantUUID(uuid); - assertEquals(uuid, ri.getResourceInvariantUUID()); - } - - @Test - public void testName() { - ResourceInstance ri = new ResourceInstance(); - String name = "nameTest"; - ri.setResourceName(name); - assertEquals(name, ri.getResourceName()); - } - - @Test - public void testVersion() { - ResourceInstance ri = new ResourceInstance(); - String version = "versionTest"; - ri.setResourceVersion(version); - assertEquals(version, ri.getResourceVersion()); - } - - @Test - public void testType() { - ResourceInstance ri = new ResourceInstance(); - ri.setResourceType(ResourceType.CP); - assertEquals(ResourceType.CP, ri.getResourceType()); - } - - @Test - public void testEquals() { - ResourceInstance ri1 = new ResourceInstance(); - ResourceInstance ri2 = new ResourceInstance(ri1); - assertTrue(ri1.equals(ri2)); - assertTrue(ri2.equals(ri1)); - - ri1.setResourceInstanceName("instance"); - ri1.setResourceName("resource"); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceVersion("0.0.0"); - ri1.setResourceType(ResourceType.VL); - ri2 = new ResourceInstance(ri1); - assertTrue(ri1.equals(ri2)); - assertTrue(ri2.equals(ri1)); - } - - @Test - public void testToString() { - ResourceInstance ri1 = new ResourceInstance(); - ResourceInstance ri2 = new ResourceInstance(ri1); - assertEquals(ri1.toString(), ri2.toString()); - - ri1.setResourceInstanceName("instance"); - ri1.setResourceName("resource"); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceVersion("0.0.0"); - ri1.setResourceType(ResourceType.VL); - ri2 = new ResourceInstance(ri1); - assertEquals(ri1.toString(), ri2.toString()); - } - - @Test - public void testHashCode() { - ResourceInstance ri1 = new ResourceInstance(); - ResourceInstance ri2 = new ResourceInstance(ri1); - assertEquals(ri1.hashCode(), ri2.hashCode()); - - ri1.setResourceInstanceName("instance"); - ri1.setResourceName("resource"); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceInvariantUUID(UUID.randomUUID()); - ri1.setResourceVersion("0.0.0"); - ri1.setResourceType(ResourceType.VL); - ri2 = new ResourceInstance(ri1); - assertEquals(ri1.hashCode(), ri2.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestService.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestService.java deleted file mode 100644 index e5760236b..000000000 --- a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestService.java +++ /dev/null @@ -1,137 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.junit.Test; - -public class TestService { - - @Test - public void testConstructors() { - Service svc = new Service(); - assertEquals(null, svc.getServiceUUID()); - assertEquals(null, svc.getServiceInvariantUUID()); - assertEquals(null, svc.getServiceName()); - assertEquals(null, svc.getServiceVersion()); - - UUID uuid = UUID.randomUUID(); - svc = new Service(uuid); - assertEquals(uuid, svc.getServiceUUID()); - assertEquals(null, svc.getServiceInvariantUUID()); - assertEquals(null, svc.getServiceName()); - assertEquals(null, svc.getServiceVersion()); - - String name = "constTest"; - svc = new Service(name); - assertEquals(null, svc.getServiceUUID()); - assertEquals(name, svc.getServiceName()); - assertEquals(null, svc.getServiceInvariantUUID()); - assertEquals(null, svc.getServiceVersion()); - - uuid = UUID.randomUUID(); - UUID uuidInvariant = UUID.randomUUID(); - name = "constTestUUID"; - String version = "0.0.1"; - svc = new Service(uuid, uuidInvariant, name, version); - assertEquals(uuid, svc.getServiceUUID()); - assertEquals(uuidInvariant, svc.getServiceInvariantUUID()); - assertEquals(name, svc.getServiceName()); - assertEquals(version, svc.getServiceVersion()); - - Service s2 = new Service(svc); - assertEquals(uuid, s2.getServiceUUID()); - assertEquals(uuidInvariant, s2.getServiceInvariantUUID()); - assertEquals(name, s2.getServiceName()); - assertEquals(version, s2.getServiceVersion()); - } - - @Test - public void testUuid() { - Service svc = new Service(); - UUID uuid = UUID.randomUUID(); - svc.setServiceUUID(uuid); - assertEquals(uuid, svc.getServiceUUID()); - } - - @Test - public void testInvariantUuid() { - Service svc = new Service(); - UUID uuid = UUID.randomUUID(); - svc.setServiceInvariantUUID(uuid); - assertEquals(uuid, svc.getServiceInvariantUUID()); - } - - @Test - public void testName() { - Service svc = new Service(); - String name = "nameTest"; - svc.setServiceName(name); - assertEquals(name, svc.getServiceName()); - } - - @Test - public void testVersion() { - Service svc = new Service(); - String version = "versionTest"; - svc.setServiceVersion(version); - assertEquals(version, svc.getServiceVersion()); - } - - @Test - public void testEquals() { - Service s1 = new Service(); - Service s2 = new Service(s1); - assertTrue(s1.equals(s2)); - assertTrue(s2.equals(s1)); - - s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1"); - s2 = new Service(s1); - assertTrue(s1.equals(s2)); - assertTrue(s2.equals(s1)); - } - - @Test - public void testToString() { - Service s1 = new Service(); - Service s2 = new Service(s1); - assertEquals(s1.toString(), s2.toString()); - - s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1"); - s2 = new Service(s1); - assertEquals(s1.toString(), s2.toString()); - } - - @Test - public void testHashCode() { - Service s1 = new Service(); - Service s2 = new Service(s1); - assertEquals(s1.hashCode(), s2.hashCode()); - - s1 = new Service(UUID.randomUUID(), UUID.randomUUID(), "equalsTest", "1.1.1"); - s2 = new Service(s1); - assertEquals(s1.hashCode(), s2.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestServiceInstance.java b/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestServiceInstance.java deleted file mode 100644 index 5ee4a9de8..000000000 --- a/controlloop/common/model-impl/sdc/src/test/java/org/onap/policy/sdc/TestServiceInstance.java +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdc - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.UUID; - -import org.junit.Test; - -public class TestServiceInstance { - - @Test - public void testConstructors() { - ServiceInstance si = new ServiceInstance(); - assertEquals(null, si.getServiceInstanceName()); - assertEquals(null, si.getServiceUUID()); - assertEquals(null, si.getServiceInstanceUUID()); - assertEquals(null, si.getServiceName()); - assertEquals(null, si.getPersonaModelUUID()); - assertEquals(null, si.getWidgetModelUUID()); - assertEquals(null, si.getWidgetModelVersion()); - - ServiceInstance si2 = new ServiceInstance((ServiceInstance) null); - assertEquals(null, si2.getServiceInstanceName()); - assertEquals(null, si2.getServiceUUID()); - assertEquals(null, si2.getServiceInstanceUUID()); - assertEquals(null, si2.getServiceName()); - assertEquals(null, si2.getPersonaModelUUID()); - assertEquals(null, si2.getWidgetModelUUID()); - assertEquals(null, si2.getWidgetModelVersion()); - - si2 = new ServiceInstance(si); - assertEquals(si2.getServiceInstanceName(), si.getServiceInstanceName()); - assertEquals(si2.getServiceUUID(), si.getServiceUUID()); - assertEquals(si2.getServiceInstanceUUID(), si.getServiceInstanceUUID()); - assertEquals(si2.getServiceName(), si.getServiceName()); - assertEquals(si2.getPersonaModelUUID(), si.getPersonaModelUUID()); - assertEquals(si2.getWidgetModelUUID(), si.getWidgetModelUUID()); - assertEquals(si2.getWidgetModelVersion(), si.getWidgetModelVersion()); - } - - @Test - public void testInstanceName() { - ServiceInstance si = new ServiceInstance(); - String name = "nameTestInstance"; - si.setServiceInstanceName(name);; - assertEquals(name, si.getServiceInstanceName()); - } - - @Test - public void testUuid() { - ServiceInstance si = new ServiceInstance(); - UUID uuid = UUID.randomUUID(); - si.setServiceUUID(uuid); - assertEquals(uuid, si.getServiceUUID()); - } - - @Test - public void testInstanceUuid() { - ServiceInstance si = new ServiceInstance(); - UUID uuid = UUID.randomUUID(); - si.setServiceInstanceUUID(uuid); - assertEquals(uuid, si.getServiceInstanceUUID()); - } - - @Test - public void testName() { - ServiceInstance si = new ServiceInstance(); - String name = "nameTest"; - si.setServiceName(name); - assertEquals(name, si.getServiceName()); - } - - @Test - public void testPersonaModelUuid() { - ServiceInstance si = new ServiceInstance(); - UUID uuid = UUID.randomUUID(); - si.setPersonaModelUUID(uuid); - assertEquals(uuid, si.getPersonaModelUUID()); - } - - @Test - public void testWidgetModelUuid() { - ServiceInstance si = new ServiceInstance(); - UUID uuid = UUID.randomUUID(); - si.setWidgetModelUUID(uuid); - assertEquals(uuid, si.getWidgetModelUUID()); - } - - @Test - public void testWidgetModelVersion() { - ServiceInstance si = new ServiceInstance(); - String version = "2.2.2"; - si.setWidgetModelVersion(version);; - assertEquals(version, si.getWidgetModelVersion()); - } - - @Test - public void testEquals() { - ServiceInstance si1 = new ServiceInstance(); - ServiceInstance si2 = new ServiceInstance(si1); - assertTrue(si1.equals(si2)); - assertTrue(si2.equals(si1)); - - si1.setServiceInstanceName("instance"); - si1.setServiceName("service"); - si1.setServiceInstanceUUID(UUID.randomUUID()); - si1.setServiceUUID(UUID.randomUUID()); - si1.setPersonaModelUUID(UUID.randomUUID()); - si1.setWidgetModelUUID(UUID.randomUUID()); - si1.setWidgetModelVersion("3.3.3"); - si2 = new ServiceInstance(si1); - assertTrue(si1.equals(si2)); - assertTrue(si2.equals(si1)); - } - - @Test - public void testToString() { - ServiceInstance si1 = new ServiceInstance(); - ServiceInstance si2 = new ServiceInstance(si1); - assertEquals(si1.toString(), si2.toString()); - - si1.setServiceInstanceName("instance"); - si1.setServiceName("service"); - si1.setServiceInstanceUUID(UUID.randomUUID()); - si1.setServiceUUID(UUID.randomUUID()); - si1.setPersonaModelUUID(UUID.randomUUID()); - si1.setWidgetModelUUID(UUID.randomUUID()); - si1.setWidgetModelVersion("3.3.3"); - si2 = new ServiceInstance(si1); - assertEquals(si1.toString(), si2.toString()); - } - - @Test - public void testHashCode() { - ServiceInstance si1 = new ServiceInstance(); - ServiceInstance si2 = new ServiceInstance(si1); - assertEquals(si1.hashCode(), si2.hashCode()); - - si1.setServiceInstanceName("instance"); - si1.setServiceName("service"); - si1.setServiceInstanceUUID(UUID.randomUUID()); - si1.setServiceUUID(UUID.randomUUID()); - si1.setPersonaModelUUID(UUID.randomUUID()); - si1.setWidgetModelUUID(UUID.randomUUID()); - si1.setWidgetModelVersion("3.3.3"); - si2 = new ServiceInstance(si1); - assertEquals(si1.hashCode(), si2.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java new file mode 100644 index 000000000..843f24dd1 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/DemoTest.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2018 Huawei. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import java.util.LinkedList; + +import org.junit.Test; +import org.onap.policy.sdnc.util.Serialization; + +public class DemoTest { + + @Test + public void test() { + SdncRequest request = new SdncRequest(); + + request.setNsInstanceId("100"); + request.setHealRequest(new SdncHealRequest()); + + request.getHealRequest().setRequestHeaderInfo(new SdncHealRequestHeaderInfo()); + request.getHealRequest().getRequestHeaderInfo().setSvcRequestId("service-req-01"); + request.getHealRequest().getRequestHeaderInfo().setSvcAction("servive-action"); + + request.getHealRequest().setRequestInfo(new SdncHealRequestInfo()); + request.getHealRequest().getRequestInfo().setRequestAction("request-action"); + + request.getHealRequest().setServiceInfo(new SdncHealServiceInfo()); + request.getHealRequest().getServiceInfo().setServiceInstanceId("service-instance-01"); + + request.getHealRequest().setNetworkInfo(new SdncHealNetworkInfo()); + request.getHealRequest().getNetworkInfo().setNetworkId("network-5555"); + + + String body = Serialization.gsonPretty.toJson(request); + System.out.println(body); + + SdncResponse response = new SdncResponse(); + + body = Serialization.gsonPretty.toJson(response); + System.out.println(body); + + response.setRequestId("request-01"); + response.setResponseOutput(new SdncResponseOutput()); + response.getResponseOutput().setSvcRequestId("service-req-01"); + response.getResponseOutput().setResponseCode("200"); + response.getResponseOutput().setAckFinalIndicator("final-indicator-00"); + + body = Serialization.gsonPretty.toJson(response); + System.out.println(body); + + response = Serialization.gsonPretty.fromJson(body, SdncResponse.class); + body = Serialization.gsonPretty.toJson(response); + System.out.println(body); + + } +} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealAdditionalParamsTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealAdditionalParamsTest.java new file mode 100644 index 000000000..0403dd0a5 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealAdditionalParamsTest.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Huawei. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class SdncHealAdditionalParamsTest { + + @Test + public void testSdncHealAdditionalParameters() { + SdncHealRequestHeaderInfo additionalParams = new SdncHealRequestHeaderInfo(); + assertNotNull(additionalParams); + assertNotEquals(0, additionalParams.hashCode()); + + String action = "Go Home"; + additionalParams.setSvcAction(action); + assertEquals(action, additionalParams.getSvcAction()); + + String requestId = "My Request"; + additionalParams.setSvcRequestId(requestId); + assertEquals(requestId, additionalParams.getSvcRequestId()); + + assertNotEquals(0, additionalParams.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealRequestTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealRequestTest.java new file mode 100644 index 000000000..705d3573f --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealRequestTest.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Huawei. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class SdncHealRequestTest { + + @Test + public void testSdncHealRequest() { + SdncHealRequest request = new SdncHealRequest(); + assertNotNull(request); + assertNotEquals(0, request.hashCode()); + + SdncHealRequestInfo requestInfo = new SdncHealRequestInfo(); + request.setRequestInfo(requestInfo); + assertEquals(requestInfo, request.getRequestInfo()); + + assertNotEquals(0, request.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealServiceInfoTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealServiceInfoTest.java new file mode 100644 index 000000000..17791a1d9 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncHealServiceInfoTest.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * sdnc + * ================================================================================ + * Copyright (C) 2018 Huawei. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class SdncHealServiceInfoTest { + + @Test + public void testSdncHealServiceInfo() { + SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo(); + assertNotNull(serviceInfo); + assertNotEquals(0, serviceInfo.hashCode()); + + String svrid = "ECity"; + serviceInfo.setServiceInstanceId(svrid); + assertEquals(svrid, serviceInfo.getServiceInstanceId()); + + assertNotEquals(0, serviceInfo.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java new file mode 100644 index 000000000..b5ddec1be --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncManagerTest.java @@ -0,0 +1,281 @@ +/*- + * ============LICENSE_START======================================================= + * sdnc + * ================================================================================ + * Copyright (C) 2018 Huawei. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.endsWith; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.startsWith; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.drools.core.WorkingMemory; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.rest.RESTManager; +import org.onap.policy.rest.RESTManager.Pair; +import org.onap.policy.sdnc.util.Serialization; + +public class SdncManagerTest { + private static WorkingMemory mockedWorkingMemory; + + private RESTManager mockedRestManager; + + private Pair httpResponsePutOk; + private Pair httpResponseGetOk; + private Pair httpResponseBadResponse; + private Pair httpResponseErr; + + private SdncRequest request; + private SdncResponse response; + + @BeforeClass + public static void beforeTestSdncManager() { + mockedWorkingMemory = mock(WorkingMemory.class); + } + + /** + * Set up the mocked REST manager. + */ + @Before + public void setupMockedRest() { + mockedRestManager = mock(RESTManager.class); + + httpResponsePutOk = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(response)); + httpResponseGetOk = mockedRestManager.new Pair<>(200, Serialization.gsonPretty.toJson(response)); + httpResponseBadResponse = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(null)); + httpResponseErr = mockedRestManager.new Pair<>(200, null); + } + + /** + * Create the request and response before. + */ + @Before + public void createRequestAndResponse() { + SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo(); + serviceInfo.setServiceInstanceId("E-City"); + + SdncHealRequestHeaderInfo additionalParams = new SdncHealRequestHeaderInfo(); + additionalParams.setSvcAction("Go Home"); + additionalParams.setSvcRequestId("My Request"); + + SdncHealRequest healRequest = new SdncHealRequest(); + healRequest.setRequestHeaderInfo(additionalParams); + healRequest.setServiceInfo(serviceInfo); + + UUID requestId = UUID.randomUUID(); + request = new SdncRequest(); + request.setRequestId(requestId); + request.setHealRequest(healRequest); + request.setNsInstanceId("Dorothy"); + + SdncResponseOutput responseDescriptor = new SdncResponseOutput(); + responseDescriptor.setSvcRequestId("1234"); + responseDescriptor.setResponseCode("200"); + responseDescriptor.setAckFinalIndicator("final-indicator-00"); + + response = new SdncResponse(); + response.setRequestId(request.getRequestId().toString()); + response.setResponseOutput(responseDescriptor); + } + + /** + * After Test clean up. + */ + @After + public void afterTestSdncManager() throws InterruptedException { + PolicyEngine.manager.getEnvironment().remove("sdnc.password"); + PolicyEngine.manager.getEnvironment().remove("sdnc.username"); + PolicyEngine.manager.getEnvironment().remove("sdnc.url"); + } + + @Test + public void testSdncInitiation() throws InterruptedException { + try { + new SdncManager(null, null); + fail("test should throw an exception here"); + } + catch (IllegalArgumentException e) { + assertEquals( + "the parameters \"wm\" and \"request\" on the SdncManager constructor may not be null", + e.getMessage() + ); + } + + try { + new SdncManager(mockedWorkingMemory, null); + fail("test should throw an exception here"); + } + catch (IllegalArgumentException e) { + assertEquals( + "the parameters \"wm\" and \"request\" on the SdncManager constructor may not be null", + e.getMessage() + ); + } + + try { + new SdncManager(mockedWorkingMemory, request); + fail("test should throw an exception here"); + } + catch (IllegalArgumentException e) { + assertEquals( + "The value of policy engine manager environment property \"sdnc.url\" may not be null", + e.getMessage() + ); + } + + PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); + try { + new SdncManager(mockedWorkingMemory, request); + fail("test should throw an exception here"); + } + catch (IllegalArgumentException e) { + assertEquals( + "The value of policy engine manager environment property \"sdnc.username\" may not be null", + e.getMessage() + ); + } + + PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); + try { + new SdncManager(mockedWorkingMemory, request); + fail("test should throw an exception here"); + } + catch (IllegalArgumentException e) { + assertEquals( + "The value of policy engine manager environment property \"sdnc.password\" may not be null", + e.getMessage() + ); + } + + PolicyEngine.manager.getEnvironment().put("sdnc.password", "Toto"); + new SdncManager(mockedWorkingMemory, request); + } + + @Test + public void testSdncExecutionException() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("sdnc.password", "Exception"); + + SdncManager manager = new SdncManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Exception"), anyMap(), anyString(), anyString())) + .thenThrow(new RuntimeException("OzException")); + + + managerThread.join(100); + } + + @Test + public void testSdncExecutionNull() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("sdnc.password", "Null"); + + SdncManager manager = new SdncManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Null"), anyMap(), anyString(), anyString())) + .thenReturn(null); + + managerThread.join(100); + } + + + @Test + public void testSdncExecutionError0() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("sdnc.password", "Error0"); + + SdncManager manager = new SdncManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Error0"), anyMap(), anyString(), anyString())) + .thenReturn(httpResponseErr); + + managerThread.join(100); + } + + @Test + public void testSdncExecutionBadResponse() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("sdnc.password", "BadResponse"); + + SdncManager manager = new SdncManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) + .thenReturn(httpResponseBadResponse); + + managerThread.join(100); + } + + @Test + public void testSdncExecutionOk() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("sdnc.password", "OK"); + + SdncManager manager = new SdncManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) + .thenReturn(httpResponsePutOk); + + when(mockedRestManager.get(endsWith("1234"), eq("Dorothy"), eq("OK"), anyMap())) + .thenReturn(httpResponseGetOk); + + + managerThread.join(100); + } +} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncRequestTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncRequestTest.java new file mode 100644 index 000000000..0c8a44898 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncRequestTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * sdnc + * ================================================================================ + * Copyright (C) 2018 Huawei. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.UUID; + +import org.junit.Test; + +public class SdncRequestTest { + + @Test + public void testSdncRequest() { + SdncRequest request = new SdncRequest(); + assertNotNull(request); + assertNotEquals(0, request.hashCode()); + + String nsInstanceId = "Dorothy"; + request.setNsInstanceId(nsInstanceId); + assertEquals(nsInstanceId, request.getNsInstanceId()); + + UUID requestId = UUID.randomUUID(); + request.setRequestId(requestId); + assertEquals(requestId, request.getRequestId()); + + SdncHealRequest healRequest = new SdncHealRequest(); + request.setHealRequest(healRequest); + assertEquals(healRequest, request.getHealRequest()); + + assertNotEquals(0, request.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseDescriptorTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseDescriptorTest.java new file mode 100644 index 000000000..5fdf2b3e2 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseDescriptorTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * sdnc + * ================================================================================ + * Copyright (C) 2018 Huawei. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class SdncResponseDescriptorTest { + + @Test + public void testSdncResponseDescriptor() { + SdncResponseOutput output = new SdncResponseOutput(); + assertNotNull(output); + assertNotEquals(0, output.hashCode()); + + String responseCode = "200"; + output.setResponseCode(responseCode); + assertEquals(responseCode, output.getResponseCode()); + + String svcRequest = "svc-request-01"; + output.setSvcRequestId(svcRequest); + assertEquals(svcRequest, output.getSvcRequestId()); + + String indicator = "final-indicator-00"; + output.setAckFinalIndicator(indicator); + assertEquals(indicator, output.getAckFinalIndicator()); + + assertNotEquals(0, output.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseTest.java new file mode 100644 index 000000000..aa879f04e --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/SdncResponseTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * sdnc + * ================================================================================ + * Copyright (C) 2018 Huawei. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + + +import org.junit.Test; + +public class SdncResponseTest { + + @Test + public void testSdncResponse() { + SdncResponse response = new SdncResponse(); + assertNotNull(response); + assertNotEquals(0, response.hashCode()); + + String requestId = "Get Home"; + response.setRequestId(requestId); + assertEquals(requestId, response.getRequestId()); + + SdncResponseOutput responseDescriptor = new SdncResponseOutput(); + response.setResponseOutput(responseDescriptor); + assertEquals(responseDescriptor, response.getResponseOutput()); + + assertNotEquals(0, response.hashCode()); + } +} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestDemo.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestDemo.java deleted file mode 100644 index b002b7ced..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestDemo.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onap.policy.sdnc.util.Serialization; - -public class TestDemo { - - @Test - public void test() { - SdncRequest request = new SdncRequest(); - - request.setNsInstanceId("100"); - request.setHealRequest(new SdncHealRequest()); - - request.getHealRequest().setRequestHeaderInfo(new SdncHealRequestHeaderInfo()); - request.getHealRequest().getRequestHeaderInfo().setSvcRequestId("service-req-01"); - request.getHealRequest().getRequestHeaderInfo().setSvcAction("servive-action"); - - request.getHealRequest().setRequestInfo(new SdncHealRequestInfo()); - request.getHealRequest().getRequestInfo().setRequestAction("request-action"); - - request.getHealRequest().setServiceInfo(new SdncHealServiceInfo()); - request.getHealRequest().getServiceInfo().setServiceInstanceId("service-instance-01"); - - request.getHealRequest().setNetworkInfo(new SdncHealNetworkInfo()); - request.getHealRequest().getNetworkInfo().setNetworkId("network-5555"); - - - String body = Serialization.gsonPretty.toJson(request); - System.out.println(body); - - SdncResponse response = new SdncResponse(); - - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - response.setRequestId("request-01"); - response.setResponseOutput(new SdncResponseOutput()); - response.getResponseOutput().setSvcRequestId("service-req-01"); - response.getResponseOutput().setResponseCode("200"); - response.getResponseOutput().setAckFinalIndicator("final-indicator-00"); - - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - response = Serialization.gsonPretty.fromJson(body, SdncResponse.class); - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealAdditionalParams.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealAdditionalParams.java deleted file mode 100644 index a282ddc39..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealAdditionalParams.java +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class TestSdncHealAdditionalParams { - - @Test - public void testSdncHealAdditionalParameters() { - SdncHealRequestHeaderInfo additionalParams = new SdncHealRequestHeaderInfo(); - assertNotNull(additionalParams); - assertNotEquals(0, additionalParams.hashCode()); - - String action = "Go Home"; - additionalParams.setSvcAction(action); - assertEquals(action, additionalParams.getSvcAction()); - - String requestId = "My Request"; - additionalParams.setSvcRequestId(requestId); - assertEquals(requestId, additionalParams.getSvcRequestId()); - - assertNotEquals(0, additionalParams.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealRequest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealRequest.java deleted file mode 100644 index 96d19b7e1..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealRequest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class TestSdncHealRequest { - - @Test - public void testSdncHealRequest() { - SdncHealRequest request = new SdncHealRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - SdncHealRequestInfo requestInfo = new SdncHealRequestInfo(); - request.setRequestInfo(requestInfo); - assertEquals(requestInfo, request.getRequestInfo()); - - assertNotEquals(0, request.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealServiceInfo.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealServiceInfo.java deleted file mode 100644 index 92bb4a727..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncHealServiceInfo.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class TestSdncHealServiceInfo { - - @Test - public void testSdncHealServiceInfo() { - SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo(); - assertNotNull(serviceInfo); - assertNotEquals(0, serviceInfo.hashCode()); - - String svrid = "ECity"; - serviceInfo.setServiceInstanceId(svrid); - assertEquals(svrid, serviceInfo.getServiceInstanceId()); - - assertNotEquals(0, serviceInfo.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncManager.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncManager.java deleted file mode 100644 index ec6c0a5f1..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncManager.java +++ /dev/null @@ -1,281 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.endsWith; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.startsWith; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.drools.core.WorkingMemory; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RESTManager; -import org.onap.policy.rest.RESTManager.Pair; -import org.onap.policy.sdnc.util.Serialization; - -public class TestSdncManager { - private static WorkingMemory mockedWorkingMemory; - - private RESTManager mockedRestManager; - - private Pair httpResponsePutOk; - private Pair httpResponseGetOk; - private Pair httpResponseBadResponse; - private Pair httpResponseErr; - - private SdncRequest request; - private SdncResponse response; - - @BeforeClass - public static void beforeTestSdncManager() { - mockedWorkingMemory = mock(WorkingMemory.class); - } - - /** - * Set up the mocked REST manager. - */ - @Before - public void setupMockedRest() { - mockedRestManager = mock(RESTManager.class); - - httpResponsePutOk = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(response)); - httpResponseGetOk = mockedRestManager.new Pair<>(200, Serialization.gsonPretty.toJson(response)); - httpResponseBadResponse = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(null)); - httpResponseErr = mockedRestManager.new Pair<>(200, null); - } - - /** - * Create the request and response before. - */ - @Before - public void createRequestAndResponse() { - SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo(); - serviceInfo.setServiceInstanceId("E-City"); - - SdncHealRequestHeaderInfo additionalParams = new SdncHealRequestHeaderInfo(); - additionalParams.setSvcAction("Go Home"); - additionalParams.setSvcRequestId("My Request"); - - SdncHealRequest healRequest = new SdncHealRequest(); - healRequest.setRequestHeaderInfo(additionalParams); - healRequest.setServiceInfo(serviceInfo); - - UUID requestId = UUID.randomUUID(); - request = new SdncRequest(); - request.setRequestId(requestId); - request.setHealRequest(healRequest); - request.setNsInstanceId("Dorothy"); - - SdncResponseOutput responseDescriptor = new SdncResponseOutput(); - responseDescriptor.setSvcRequestId("1234"); - responseDescriptor.setResponseCode("200"); - responseDescriptor.setAckFinalIndicator("final-indicator-00"); - - response = new SdncResponse(); - response.setRequestId(request.getRequestId().toString()); - response.setResponseOutput(responseDescriptor); - } - - /** - * After Test clean up. - */ - @After - public void afterTestSdncManager() throws InterruptedException { - PolicyEngine.manager.getEnvironment().remove("sdnc.password"); - PolicyEngine.manager.getEnvironment().remove("sdnc.username"); - PolicyEngine.manager.getEnvironment().remove("sdnc.url"); - } - - @Test - public void testSdncInitiation() throws InterruptedException { - try { - new SdncManager(null, null); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "the parameters \"wm\" and \"request\" on the SdncManager constructor may not be null", - e.getMessage() - ); - } - - try { - new SdncManager(mockedWorkingMemory, null); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "the parameters \"wm\" and \"request\" on the SdncManager constructor may not be null", - e.getMessage() - ); - } - - try { - new SdncManager(mockedWorkingMemory, request); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "The value of policy engine manager environment property \"sdnc.url\" may not be null", - e.getMessage() - ); - } - - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - try { - new SdncManager(mockedWorkingMemory, request); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "The value of policy engine manager environment property \"sdnc.username\" may not be null", - e.getMessage() - ); - } - - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - try { - new SdncManager(mockedWorkingMemory, request); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals( - "The value of policy engine manager environment property \"sdnc.password\" may not be null", - e.getMessage() - ); - } - - PolicyEngine.manager.getEnvironment().put("sdnc.password", "Toto"); - new SdncManager(mockedWorkingMemory, request); - } - - @Test - public void testSdncExecutionException() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "Exception"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Exception"), anyMap(), anyString(), anyString())) - .thenThrow(new RuntimeException("OzException")); - - - managerThread.join(100); - } - - @Test - public void testSdncExecutionNull() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "Null"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Null"), anyMap(), anyString(), anyString())) - .thenReturn(null); - - managerThread.join(100); - } - - - @Test - public void testSdncExecutionError0() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "Error0"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("Error0"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponseErr); - - managerThread.join(100); - } - - @Test - public void testSdncExecutionBadResponse() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "BadResponse"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponseBadResponse); - - managerThread.join(100); - } - - @Test - public void testSdncExecutionOk() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("sdnc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("sdnc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("sdnc.password", "OK"); - - SdncManager manager = new SdncManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponsePutOk); - - when(mockedRestManager.get(endsWith("1234"), eq("Dorothy"), eq("OK"), anyMap())) - .thenReturn(httpResponseGetOk); - - - managerThread.join(100); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncRequest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncRequest.java deleted file mode 100644 index adb07b947..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncRequest.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.Test; - -public class TestSdncRequest { - - @Test - public void testSdncRequest() { - SdncRequest request = new SdncRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - String nsInstanceId = "Dorothy"; - request.setNsInstanceId(nsInstanceId); - assertEquals(nsInstanceId, request.getNsInstanceId()); - - UUID requestId = UUID.randomUUID(); - request.setRequestId(requestId); - assertEquals(requestId, request.getRequestId()); - - SdncHealRequest healRequest = new SdncHealRequest(); - request.setHealRequest(healRequest); - assertEquals(healRequest, request.getHealRequest()); - - assertNotEquals(0, request.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponse.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponse.java deleted file mode 100644 index 5daa12ab9..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponse.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - - -import org.junit.Test; - -public class TestSdncResponse { - - @Test - public void testSdncResponse() { - SdncResponse response = new SdncResponse(); - assertNotNull(response); - assertNotEquals(0, response.hashCode()); - - String requestId = "Get Home"; - response.setRequestId(requestId); - assertEquals(requestId, response.getRequestId()); - - SdncResponseOutput responseDescriptor = new SdncResponseOutput(); - response.setResponseOutput(responseDescriptor); - assertEquals(responseDescriptor, response.getResponseOutput()); - - assertNotEquals(0, response.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponseDescriptor.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponseDescriptor.java deleted file mode 100644 index 5c882282b..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/TestSdncResponseDescriptor.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnc - * ================================================================================ - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class TestSdncResponseDescriptor { - - @Test - public void testSdncResponseDescriptor() { - SdncResponseOutput output = new SdncResponseOutput(); - assertNotNull(output); - assertNotEquals(0, output.hashCode()); - - String responseCode = "200"; - output.setResponseCode(responseCode); - assertEquals(responseCode, output.getResponseCode()); - - String svcRequest = "svc-request-01"; - output.setSvcRequestId(svcRequest); - assertEquals(svcRequest, output.getSvcRequestId()); - - String indicator = "final-indicator-00"; - output.setAckFinalIndicator(indicator); - assertEquals(indicator, output.getAckFinalIndicator()); - - assertNotEquals(0, output.hashCode()); - } -} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/SerializationTest.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/SerializationTest.java new file mode 100644 index 000000000..9b3ab7856 --- /dev/null +++ b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/SerializationTest.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Huawei. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class SerializationTest { + + @Test + public void test() { + assertNotNull(Serialization.gsonPretty); + } +} diff --git a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/TestSerialization.java b/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/TestSerialization.java deleted file mode 100644 index 9d02d4f87..000000000 --- a/controlloop/common/model-impl/sdnc/src/test/java/org/onap/policy/sdnc/util/TestSerialization.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Huawei. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnc.util; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class TestSerialization { - - @Test - public void test() { - assertNotNull(Serialization.gsonPretty); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java new file mode 100644 index 000000000..4b3201440 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciCommonHeaderTest.java @@ -0,0 +1,144 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnr; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.time.Instant; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.junit.Test; + +public class PciCommonHeaderTest { + + @Test + public void testPciCommonHeader() { + PciCommonHeader commonHeader = new PciCommonHeader(); + assertNotNull(commonHeader); + assertNotNull(new PciCommonHeader(commonHeader)); + assertNotEquals(0, commonHeader.hashCode()); + + commonHeader.setApiVer("Kansas"); + assertEquals("Kansas", commonHeader.getApiVer()); + + Map flagMap = new HashMap<>(); + commonHeader.setFlags(flagMap); + assertEquals(flagMap, commonHeader.getFlags()); + + Map requestMap = new HashMap<>(); + commonHeader.setRequestTrack(requestMap); + assertEquals(requestMap, commonHeader.getRequestTrack()); + + UUID requestId = UUID.randomUUID(); + commonHeader.setRequestId(requestId); + assertEquals(requestId, commonHeader.getRequestId()); + + commonHeader.setSubRequestId("Can I go home?"); + assertEquals("Can I go home?", commonHeader.getSubRequestId()); + + Instant timestamp = Instant.now(); + commonHeader.setTimeStamp(timestamp); + assertEquals(timestamp, commonHeader.getTimeStamp()); + + assertNotEquals(0, commonHeader.hashCode()); + + assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24)); + + PciCommonHeader copiedPciCommonHeader = new PciCommonHeader(); + copiedPciCommonHeader.setApiVer(commonHeader.getApiVer()); + copiedPciCommonHeader.setFlags(commonHeader.getFlags()); + copiedPciCommonHeader.setRequestId(commonHeader.getRequestId()); + copiedPciCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); + copiedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); + + assertTrue(commonHeader.equals(commonHeader)); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + assertFalse(commonHeader.equals(null)); + assertFalse(commonHeader.equals("Hello")); + + PciCommonHeader clonedPciCommonHeader = new PciCommonHeader(commonHeader); + clonedPciCommonHeader.setApiVer(commonHeader.getApiVer()); + clonedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); + + assertTrue(commonHeader.equals(clonedPciCommonHeader)); + + commonHeader.setApiVer(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setApiVer(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setApiVer("Kansas"); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setApiVer("Kansas"); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + commonHeader.setFlags(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setFlags(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setFlags(flagMap); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setFlags(flagMap); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + commonHeader.setRequestTrack(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setRequestTrack(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setRequestTrack(requestMap); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setRequestTrack(requestMap); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + + commonHeader.setRequestId(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setRequestId(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setRequestId(requestId); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setRequestId(requestId); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + commonHeader.setSubRequestId(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setSubRequestId(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setSubRequestId("Can I go home?"); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setSubRequestId("Can I go home?"); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + + commonHeader.setTimeStamp(null); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setTimeStamp(null); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + commonHeader.setTimeStamp(timestamp); + assertFalse(commonHeader.equals(copiedPciCommonHeader)); + copiedPciCommonHeader.setTimeStamp(timestamp); + assertTrue(commonHeader.equals(copiedPciCommonHeader)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java new file mode 100644 index 000000000..64d976710 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestTest.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnr; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class PciRequestTest { + + @Test + public void testPciRequest() { + PciRequest request = new PciRequest(); + assertNotNull(request); + assertNotEquals(0, request.hashCode()); + + PciCommonHeader commonHeader = new PciCommonHeader(); + String requestPayload = ""; + + request.setCommonHeader(commonHeader); + assertEquals(commonHeader, request.getCommonHeader()); + + request.setPayload(requestPayload); + assertEquals(requestPayload, request.getPayload()); + + request.setAction("Modify"); + assertEquals("Modify", request.getAction()); + + assertNotEquals(0, request.hashCode()); + + assertEquals("PciRequest[commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 48)); + + PciRequest copiedPciRequest = new PciRequest(); + copiedPciRequest.setCommonHeader(request.getCommonHeader()); + copiedPciRequest.setAction(request.getAction()); + copiedPciRequest.setPayload(request.getPayload()); + + assertTrue(request.equals(request)); + assertTrue(request.equals(copiedPciRequest)); + assertFalse(request.equals(null)); + assertFalse(request.equals("Hello")); + + request.setCommonHeader(null); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setCommonHeader(null); + assertTrue(request.equals(copiedPciRequest)); + request.setCommonHeader(commonHeader); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setCommonHeader(commonHeader); + assertTrue(request.equals(copiedPciRequest)); + + request.setAction(null); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setAction(null); + assertTrue(request.equals(copiedPciRequest)); + request.setAction("Modify"); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setAction("Modify"); + assertTrue(request.equals(copiedPciRequest)); + + request.setPayload(null); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setPayload(null); + assertTrue(request.equals(copiedPciRequest)); + request.setPayload(requestPayload); + assertFalse(request.equals(copiedPciRequest)); + copiedPciRequest.setPayload(requestPayload); + assertTrue(request.equals(copiedPciRequest)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java new file mode 100644 index 000000000..79f3c0d6f --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciRequestWrapperTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnr; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class PciRequestWrapperTest { + + @Test + public void testPciRequestWrapperWrapper() { + assertNotNull(new PciRequestWrapper(new PciRequest())); + PciRequestWrapper requestWrapper = new PciRequestWrapper(); + assertNotNull(requestWrapper); + assertNotEquals(0, requestWrapper.hashCode()); + + PciRequest request = new PciRequest(); + + requestWrapper.setBody(request); + assertEquals(request, requestWrapper.getBody()); + + assertNotEquals(0, requestWrapper.hashCode()); + + assertEquals("RequestWrapper [body=PciRequest[commonHeader=nul", requestWrapper.toString().substring(0, 48)); + + PciRequestWrapper copiedPciRequestWrapper = new PciRequestWrapper(); + copiedPciRequestWrapper.setBody(requestWrapper.getBody()); + + assertTrue(requestWrapper.equals(requestWrapper)); + assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); + assertFalse(requestWrapper.equals(null)); + assertFalse(requestWrapper.equals("Hello")); + + requestWrapper.setBody(null); + assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); + copiedPciRequestWrapper.setBody(null); + assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); + requestWrapper.setBody(request); + assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); + copiedPciRequestWrapper.setBody(request); + assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java new file mode 100644 index 000000000..355713133 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseCodeTest.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnr; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import org.junit.Test; + +public class PciResponseCodeTest { + + @Test + public void testPciResponseCode() { + assertNull(PciResponseCode.toResponseValue(0)); + + assertEquals(PciResponseCode.ACCEPTED, PciResponseCode.toResponseValue(100)); + assertEquals(PciResponseCode.SUCCESS, PciResponseCode.toResponseValue(200)); + assertEquals(PciResponseCode.REJECT, PciResponseCode.toResponseValue(300)); + assertEquals(PciResponseCode.ERROR, PciResponseCode.toResponseValue(400)); + assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(450)); + assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(401)); + assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(406)); + assertEquals(PciResponseCode.PARTIAL_SUCCESS, PciResponseCode.toResponseValue(500)); + assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(501)); + assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(599)); + + assertEquals("100", new PciResponseCode(100).toString()); + assertEquals("200", new PciResponseCode(200).toString()); + assertEquals("300", new PciResponseCode(300).toString()); + assertEquals("400", new PciResponseCode(400).toString()); + assertEquals("450", new PciResponseCode(450).toString()); + assertEquals("500", new PciResponseCode(500).toString()); + assertEquals("510", new PciResponseCode(510).toString()); + + assertEquals(300, new PciResponseCode(300).getCode()); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java new file mode 100644 index 000000000..16f6f59e9 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciResponseWrapperTest.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnr; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class PciResponseWrapperTest { + + @Test + public void testPciResponseWrapperWrapper() { + + PciResponseWrapper responseWrapper = new PciResponseWrapper(); + assertNotNull(responseWrapper); + assertNotEquals(0, responseWrapper.hashCode()); + + PciResponse response = new PciResponse(); + + responseWrapper.setBody(response); + assertEquals(response, responseWrapper.getBody()); + + assertNotEquals(0, responseWrapper.hashCode()); + + assertNotEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46)); + + PciResponseWrapper copiedPciResponseWrapper = new PciResponseWrapper(); + copiedPciResponseWrapper.setBody(responseWrapper.getBody()); + + assertTrue(responseWrapper.equals(responseWrapper)); + //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); + assertFalse(responseWrapper.equals(null)); + assertFalse(responseWrapper.equals("Hello")); + + responseWrapper.setBody(null); + assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); + copiedPciResponseWrapper.setBody(null); + //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); + responseWrapper.setBody(response); + //assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); + copiedPciResponseWrapper.setBody(response); + //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java new file mode 100644 index 000000000..b38eed3e3 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciStatusTest.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnr; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class PciStatusTest { + + @Test + public void testResponseStatus() { + Status status = new Status(); + assertNotNull(status); + assertNotEquals(0, status.hashCode()); + + status.setCode(1234); + assertEquals(1234, status.getCode()); + + status.setValue("The wonderful land of Oz"); + assertEquals("The wonderful land of Oz", status.getValue()); + + assertEquals("Status [code = 1234, value = The wonderfu", status.toString().substring(0, 41)); + + Status copiedStatus = new Status(); + copiedStatus.setCode(status.getCode()); + copiedStatus.setValue(status.getValue()); + + assertTrue(status.equals(status)); + assertTrue(status.equals(copiedStatus)); + assertFalse(status.equals(null)); + assertFalse(status.equals("Hello")); + + status.setCode(-1); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setCode(-1); + assertTrue(status.equals(copiedStatus)); + status.setCode(1234); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setCode(1234); + assertTrue(status.equals(copiedStatus)); + + status.setValue(null); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setValue(null); + assertTrue(status.equals(copiedStatus)); + status.setValue("The wonderful land of Oz"); + assertFalse(status.equals(copiedStatus)); + copiedStatus.setValue("The wonderful land of Oz"); + assertTrue(status.equals(copiedStatus)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java new file mode 100644 index 000000000..a9501dddc --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/PciWrapperTest.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnr; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class PciWrapperTest { + + @Test + public void testPciWrapper() { + PciWrapper wrapper = new PciWrapper(); + assertNotNull(wrapper); + assertNotEquals(0, wrapper.hashCode()); + + wrapper.setVersion("19.3.9"); + assertEquals("19.3.9", wrapper.getVersion()); + + wrapper.setCambriaPartition("The Emerald City"); + assertEquals("The Emerald City", wrapper.getCambriaPartition()); + + wrapper.setRpcName("Tornado"); + assertEquals("Tornado", wrapper.getRpcName()); + + wrapper.setCorrelationId("YellowBrickRoad"); + assertEquals("YellowBrickRoad", wrapper.getCorrelationId()); + + wrapper.setType("Munchkin"); + assertEquals("Munchkin", wrapper.getType()); + + assertNotEquals(0, wrapper.hashCode()); + + assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46)); + + PciWrapper copiedPciWrapper = new PciWrapper(); + copiedPciWrapper.setVersion(wrapper.getVersion()); + copiedPciWrapper.setCambriaPartition(wrapper.getCambriaPartition()); + copiedPciWrapper.setRpcName(wrapper.getRpcName()); + copiedPciWrapper.setCorrelationId(wrapper.getCorrelationId()); + copiedPciWrapper.setType(wrapper.getType()); + + assertTrue(wrapper.equals(wrapper)); + assertTrue(wrapper.equals(copiedPciWrapper)); + assertFalse(wrapper.equals(null)); + assertFalse(wrapper.equals("Hello")); + + wrapper.setVersion(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setVersion(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setVersion("19.3.9"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setVersion("19.3.9"); + assertTrue(wrapper.equals(copiedPciWrapper)); + + wrapper.setCambriaPartition(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setCambriaPartition(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setCambriaPartition("The Emerald City"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setCambriaPartition("The Emerald City"); + assertTrue(wrapper.equals(copiedPciWrapper)); + + wrapper.setRpcName(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setRpcName(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setRpcName("Tornado"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setRpcName("Tornado"); + assertTrue(wrapper.equals(copiedPciWrapper)); + + wrapper.setCorrelationId(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setCorrelationId(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setCorrelationId("YellowBrickRoad"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setCorrelationId("YellowBrickRoad"); + assertTrue(wrapper.equals(copiedPciWrapper)); + + wrapper.setType(null); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setType(null); + assertTrue(wrapper.equals(copiedPciWrapper)); + wrapper.setType("Munchkin"); + assertFalse(wrapper.equals(copiedPciWrapper)); + copiedPciWrapper.setType("Munchkin"); + assertTrue(wrapper.equals(copiedPciWrapper)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciCommonHeader.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciCommonHeader.java deleted file mode 100644 index 5c4dec3bc..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciCommonHeader.java +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.junit.Test; - -public class TestPciCommonHeader { - - @Test - public void testPciCommonHeader() { - PciCommonHeader commonHeader = new PciCommonHeader(); - assertNotNull(commonHeader); - assertNotNull(new PciCommonHeader(commonHeader)); - assertNotEquals(0, commonHeader.hashCode()); - - commonHeader.setApiVer("Kansas"); - assertEquals("Kansas", commonHeader.getApiVer()); - - Map flagMap = new HashMap<>(); - commonHeader.setFlags(flagMap); - assertEquals(flagMap, commonHeader.getFlags()); - - Map requestMap = new HashMap<>(); - commonHeader.setRequestTrack(requestMap); - assertEquals(requestMap, commonHeader.getRequestTrack()); - - UUID requestId = UUID.randomUUID(); - commonHeader.setRequestId(requestId); - assertEquals(requestId, commonHeader.getRequestId()); - - commonHeader.setSubRequestId("Can I go home?"); - assertEquals("Can I go home?", commonHeader.getSubRequestId()); - - Instant timestamp = Instant.now(); - commonHeader.setTimeStamp(timestamp); - assertEquals(timestamp, commonHeader.getTimeStamp()); - - assertNotEquals(0, commonHeader.hashCode()); - - assertEquals("CommonHeader [timeStamp=", commonHeader.toString().substring(0, 24)); - - PciCommonHeader copiedPciCommonHeader = new PciCommonHeader(); - copiedPciCommonHeader.setApiVer(commonHeader.getApiVer()); - copiedPciCommonHeader.setFlags(commonHeader.getFlags()); - copiedPciCommonHeader.setRequestId(commonHeader.getRequestId()); - copiedPciCommonHeader.setSubRequestId(commonHeader.getSubRequestId()); - copiedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(commonHeader)); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - assertFalse(commonHeader.equals(null)); - assertFalse(commonHeader.equals("Hello")); - - PciCommonHeader clonedPciCommonHeader = new PciCommonHeader(commonHeader); - clonedPciCommonHeader.setApiVer(commonHeader.getApiVer()); - clonedPciCommonHeader.setTimeStamp(commonHeader.getTimeStamp()); - - assertTrue(commonHeader.equals(clonedPciCommonHeader)); - - commonHeader.setApiVer(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setApiVer(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setApiVer("Kansas"); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setApiVer("Kansas"); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setFlags(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setFlags(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setFlags(flagMap); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setFlags(flagMap); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setRequestTrack(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestTrack(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setRequestTrack(requestMap); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestTrack(requestMap); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - - commonHeader.setRequestId(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestId(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setRequestId(requestId); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setRequestId(requestId); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setSubRequestId(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setSubRequestId(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setSubRequestId("Can I go home?"); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setSubRequestId("Can I go home?"); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - - commonHeader.setTimeStamp(null); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setTimeStamp(null); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - commonHeader.setTimeStamp(timestamp); - assertFalse(commonHeader.equals(copiedPciCommonHeader)); - copiedPciCommonHeader.setTimeStamp(timestamp); - assertTrue(commonHeader.equals(copiedPciCommonHeader)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequest.java deleted file mode 100644 index 3a84adcd4..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequest.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestPciRequest { - - @Test - public void testPciRequest() { - PciRequest request = new PciRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - PciCommonHeader commonHeader = new PciCommonHeader(); - String requestPayload = ""; - - request.setCommonHeader(commonHeader); - assertEquals(commonHeader, request.getCommonHeader()); - - request.setPayload(requestPayload); - assertEquals(requestPayload, request.getPayload()); - - request.setAction("Modify"); - assertEquals("Modify", request.getAction()); - - assertNotEquals(0, request.hashCode()); - - assertEquals("PciRequest[commonHeader=CommonHeader [timeStamp=", request.toString().substring(0, 48)); - - PciRequest copiedPciRequest = new PciRequest(); - copiedPciRequest.setCommonHeader(request.getCommonHeader()); - copiedPciRequest.setAction(request.getAction()); - copiedPciRequest.setPayload(request.getPayload()); - - assertTrue(request.equals(request)); - assertTrue(request.equals(copiedPciRequest)); - assertFalse(request.equals(null)); - assertFalse(request.equals("Hello")); - - request.setCommonHeader(null); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setCommonHeader(null); - assertTrue(request.equals(copiedPciRequest)); - request.setCommonHeader(commonHeader); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setCommonHeader(commonHeader); - assertTrue(request.equals(copiedPciRequest)); - - request.setAction(null); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setAction(null); - assertTrue(request.equals(copiedPciRequest)); - request.setAction("Modify"); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setAction("Modify"); - assertTrue(request.equals(copiedPciRequest)); - - request.setPayload(null); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setPayload(null); - assertTrue(request.equals(copiedPciRequest)); - request.setPayload(requestPayload); - assertFalse(request.equals(copiedPciRequest)); - copiedPciRequest.setPayload(requestPayload); - assertTrue(request.equals(copiedPciRequest)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequestWrapper.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequestWrapper.java deleted file mode 100644 index 7ab68a6ca..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciRequestWrapper.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestPciRequestWrapper { - - @Test - public void testPciRequestWrapperWrapper() { - assertNotNull(new PciRequestWrapper(new PciRequest())); - PciRequestWrapper requestWrapper = new PciRequestWrapper(); - assertNotNull(requestWrapper); - assertNotEquals(0, requestWrapper.hashCode()); - - PciRequest request = new PciRequest(); - - requestWrapper.setBody(request); - assertEquals(request, requestWrapper.getBody()); - - assertNotEquals(0, requestWrapper.hashCode()); - - assertEquals("RequestWrapper [body=PciRequest[commonHeader=nul", requestWrapper.toString().substring(0, 48)); - - PciRequestWrapper copiedPciRequestWrapper = new PciRequestWrapper(); - copiedPciRequestWrapper.setBody(requestWrapper.getBody()); - - assertTrue(requestWrapper.equals(requestWrapper)); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - assertFalse(requestWrapper.equals(null)); - assertFalse(requestWrapper.equals("Hello")); - - requestWrapper.setBody(null); - assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); - copiedPciRequestWrapper.setBody(null); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - requestWrapper.setBody(request); - assertFalse(requestWrapper.equals(copiedPciRequestWrapper)); - copiedPciRequestWrapper.setBody(request); - assertTrue(requestWrapper.equals(copiedPciRequestWrapper)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseCode.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseCode.java deleted file mode 100644 index 056ce60e6..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseCode.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; - -public class TestPciResponseCode { - - @Test - public void testPciResponseCode() { - assertNull(PciResponseCode.toResponseValue(0)); - - assertEquals(PciResponseCode.ACCEPTED, PciResponseCode.toResponseValue(100)); - assertEquals(PciResponseCode.SUCCESS, PciResponseCode.toResponseValue(200)); - assertEquals(PciResponseCode.REJECT, PciResponseCode.toResponseValue(300)); - assertEquals(PciResponseCode.ERROR, PciResponseCode.toResponseValue(400)); - assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(450)); - assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(401)); - assertEquals(PciResponseCode.FAILURE, PciResponseCode.toResponseValue(406)); - assertEquals(PciResponseCode.PARTIAL_SUCCESS, PciResponseCode.toResponseValue(500)); - assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(501)); - assertEquals(PciResponseCode.PARTIAL_FAILURE, PciResponseCode.toResponseValue(599)); - - assertEquals("100", new PciResponseCode(100).toString()); - assertEquals("200", new PciResponseCode(200).toString()); - assertEquals("300", new PciResponseCode(300).toString()); - assertEquals("400", new PciResponseCode(400).toString()); - assertEquals("450", new PciResponseCode(450).toString()); - assertEquals("500", new PciResponseCode(500).toString()); - assertEquals("510", new PciResponseCode(510).toString()); - - assertEquals(300, new PciResponseCode(300).getCode()); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseWrapper.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseWrapper.java deleted file mode 100644 index 2472d31c3..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciResponseWrapper.java +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestPciResponseWrapper { - - @Test - public void testPciResponseWrapperWrapper() { - - PciResponseWrapper responseWrapper = new PciResponseWrapper(); - assertNotNull(responseWrapper); - assertNotEquals(0, responseWrapper.hashCode()); - - PciResponse response = new PciResponse(); - - responseWrapper.setBody(response); - assertEquals(response, responseWrapper.getBody()); - - assertNotEquals(0, responseWrapper.hashCode()); - - assertNotEquals("ResponseWrapper [body=Response [commonHeader=n", responseWrapper.toString().substring(0, 46)); - - PciResponseWrapper copiedPciResponseWrapper = new PciResponseWrapper(); - copiedPciResponseWrapper.setBody(responseWrapper.getBody()); - - assertTrue(responseWrapper.equals(responseWrapper)); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("Hello")); - - responseWrapper.setBody(null); - assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); - copiedPciResponseWrapper.setBody(null); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - responseWrapper.setBody(response); - //assertFalse(responseWrapper.equals(copiedPciResponseWrapper)); - copiedPciResponseWrapper.setBody(response); - //assertTrue(responseWrapper.equals(copiedPciResponseWrapper)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciStatus.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciStatus.java deleted file mode 100644 index b09922342..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciStatus.java +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestPciStatus { - - @Test - public void testResponseStatus() { - Status status = new Status(); - assertNotNull(status); - assertNotEquals(0, status.hashCode()); - - status.setCode(1234); - assertEquals(1234, status.getCode()); - - status.setValue("The wonderful land of Oz"); - assertEquals("The wonderful land of Oz", status.getValue()); - - assertEquals("Status [code = 1234, value = The wonderfu", status.toString().substring(0, 41)); - - Status copiedStatus = new Status(); - copiedStatus.setCode(status.getCode()); - copiedStatus.setValue(status.getValue()); - - assertTrue(status.equals(status)); - assertTrue(status.equals(copiedStatus)); - assertFalse(status.equals(null)); - assertFalse(status.equals("Hello")); - - status.setCode(-1); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(-1); - assertTrue(status.equals(copiedStatus)); - status.setCode(1234); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setCode(1234); - assertTrue(status.equals(copiedStatus)); - - status.setValue(null); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue(null); - assertTrue(status.equals(copiedStatus)); - status.setValue("The wonderful land of Oz"); - assertFalse(status.equals(copiedStatus)); - copiedStatus.setValue("The wonderful land of Oz"); - assertTrue(status.equals(copiedStatus)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciWrapper.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciWrapper.java deleted file mode 100644 index e0964df65..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/TestPciWrapper.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnr; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestPciWrapper { - - @Test - public void testPciWrapper() { - PciWrapper wrapper = new PciWrapper(); - assertNotNull(wrapper); - assertNotEquals(0, wrapper.hashCode()); - - wrapper.setVersion("19.3.9"); - assertEquals("19.3.9", wrapper.getVersion()); - - wrapper.setCambriaPartition("The Emerald City"); - assertEquals("The Emerald City", wrapper.getCambriaPartition()); - - wrapper.setRpcName("Tornado"); - assertEquals("Tornado", wrapper.getRpcName()); - - wrapper.setCorrelationId("YellowBrickRoad"); - assertEquals("YellowBrickRoad", wrapper.getCorrelationId()); - - wrapper.setType("Munchkin"); - assertEquals("Munchkin", wrapper.getType()); - - assertNotEquals(0, wrapper.hashCode()); - - assertEquals("Wrapper [version=19.3.9, cambriaPartition=The ", wrapper.toString().substring(0, 46)); - - PciWrapper copiedPciWrapper = new PciWrapper(); - copiedPciWrapper.setVersion(wrapper.getVersion()); - copiedPciWrapper.setCambriaPartition(wrapper.getCambriaPartition()); - copiedPciWrapper.setRpcName(wrapper.getRpcName()); - copiedPciWrapper.setCorrelationId(wrapper.getCorrelationId()); - copiedPciWrapper.setType(wrapper.getType()); - - assertTrue(wrapper.equals(wrapper)); - assertTrue(wrapper.equals(copiedPciWrapper)); - assertFalse(wrapper.equals(null)); - assertFalse(wrapper.equals("Hello")); - - wrapper.setVersion(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setVersion(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setVersion("19.3.9"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setVersion("19.3.9"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setCambriaPartition(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCambriaPartition(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setCambriaPartition("The Emerald City"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCambriaPartition("The Emerald City"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setRpcName(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setRpcName(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setRpcName("Tornado"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setRpcName("Tornado"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setCorrelationId(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCorrelationId(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setCorrelationId("YellowBrickRoad"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setCorrelationId("YellowBrickRoad"); - assertTrue(wrapper.equals(copiedPciWrapper)); - - wrapper.setType(null); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setType(null); - assertTrue(wrapper.equals(copiedPciWrapper)); - wrapper.setType("Munchkin"); - assertFalse(wrapper.equals(copiedPciWrapper)); - copiedPciWrapper.setType("Munchkin"); - assertTrue(wrapper.equals(copiedPciWrapper)); - } -} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java new file mode 100644 index 000000000..e9793b286 --- /dev/null +++ b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/SerializationTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * sdnr + * ================================================================================ + * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnr.util; + +import static org.junit.Assert.assertEquals; + +import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; + +import org.junit.Test; + +public class SerializationTest { + + @Test + public void test() { + String nameString = "Dorothy"; + String jsonName = Serialization.gsonPretty.toJson(nameString, String.class); + assertEquals("\"Dorothy\"", jsonName); + String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class); + assertEquals("Dorothy", jsonInOutName); + + Instant instant0 = Instant.ofEpochMilli(1516127215000L); + String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class); + assertEquals("\"2018-01-16T18:26:55Z\"", instantString0); + Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class); + assertEquals(instant0, outInstant0); + + Instant instant1 = Instant.ofEpochMilli(1516127215000L); + String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class); + assertEquals("1516127215000", instantString1); + Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class); + assertEquals(instant1, outInstant1); + + ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC")); + String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class); + assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29)); + } +} diff --git a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/TestSerialization.java b/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/TestSerialization.java deleted file mode 100644 index 7b139de73..000000000 --- a/controlloop/common/model-impl/sdnr/src/test/java/org/onap/policy/sdnr/util/TestSerialization.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * sdnr - * ================================================================================ - * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.sdnr.util; - -import static org.junit.Assert.assertEquals; - -import java.time.Instant; -import java.time.ZoneId; -import java.time.ZonedDateTime; - -import org.junit.Test; - -public class TestSerialization { - - @Test - public void test() { - String nameString = "Dorothy"; - String jsonName = Serialization.gsonPretty.toJson(nameString, String.class); - assertEquals("\"Dorothy\"", jsonName); - String jsonInOutName = Serialization.gsonPretty.fromJson(jsonName, String.class); - assertEquals("Dorothy", jsonInOutName); - - Instant instant0 = Instant.ofEpochMilli(1516127215000L); - String instantString0 = Serialization.gsonPretty.toJson(instant0, Instant.class); - assertEquals("\"2018-01-16T18:26:55Z\"", instantString0); - Instant outInstant0 = Serialization.gsonPretty.fromJson(instantString0, Instant.class); - assertEquals(instant0, outInstant0); - - Instant instant1 = Instant.ofEpochMilli(1516127215000L); - String instantString1 = Serialization.gsonJunit.toJson(instant1, Instant.class); - assertEquals("1516127215000", instantString1); - Instant outInstant1 = Serialization.gsonJunit.fromJson(instantString1, Instant.class); - assertEquals(instant1, outInstant1); - - ZonedDateTime zdt = ZonedDateTime.ofInstant(instant0, ZoneId.of("UTC")); - String zdtString = Serialization.gsonPretty.toJson(zdt, ZonedDateTime.class); - assertEquals("{\n \"dateTime\": {\n \"date\":", zdtString.substring(0, 29)); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java new file mode 100644 index 000000000..43cce61e1 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java @@ -0,0 +1,186 @@ +/*- + * ============LICENSE_START======================================================= + * mso + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.policy.so.SOCloudConfiguration; +import org.onap.policy.so.SOModelInfo; +import org.onap.policy.so.SORelatedInstance; +import org.onap.policy.so.SORelatedInstanceListElement; +import org.onap.policy.so.SORequest; +import org.onap.policy.so.SORequestDetails; +import org.onap.policy.so.SORequestInfo; +import org.onap.policy.so.SORequestParameters; +import org.onap.policy.so.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DemoTest { + private static final Logger logger = LoggerFactory.getLogger(DemoTest.class); + + @Test + public void test() { + + SORequest request = new SORequest(); + request.setRequestDetails(new SORequestDetails()); + request.getRequestDetails().setModelInfo(new SOModelInfo()); + request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); + request.getRequestDetails().setRequestInfo(new SORequestInfo()); + request.getRequestDetails().setRequestParameters(new SORequestParameters()); + + request.getRequestDetails().getModelInfo().setModelType("vfModule"); + request.getRequestDetails().getModelInfo().setModelInvariantId("ff5256d2-5a33-55df-13ab-12abad84e7ff"); + request.getRequestDetails().getModelInfo().setModelVersionId("fe6478e5-ea33-3346-ac12-ab121484a3fe"); + request.getRequestDetails().getModelInfo().setModelName("vSAMP12..base..module-0"); + request.getRequestDetails().getModelInfo().setModelVersion("1"); + + request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("mdt1"); + request.getRequestDetails().getCloudConfiguration().setTenantId("88a6ca3ee0394ade9403f075db23167e"); + + request.getRequestDetails().getRequestInfo().setInstanceName("SOTEST103a-vSAMP12_base_module-0"); + request.getRequestDetails().getRequestInfo().setSource("VID"); + request.getRequestDetails().getRequestInfo().setSuppressRollback(true); + + SORelatedInstanceListElement relatedInstanceListElement1 = + new SORelatedInstanceListElement(); + SORelatedInstanceListElement relatedInstanceListElement2 = + new SORelatedInstanceListElement(); + SORelatedInstanceListElement relatedInstanceListElement3 = + new SORelatedInstanceListElement(); + relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement3.setRelatedInstance(new SORelatedInstance()); + + relatedInstanceListElement1.getRelatedInstance().setInstanceId( + "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c"); + relatedInstanceListElement1.getRelatedInstance().setInstanceName( + "SOTESTVOL103a-vSAMP12_base_module-0_vol"); + relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("volumeGroup"); + + relatedInstanceListElement2.getRelatedInstance().setInstanceId("serviceInstanceId"); + relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("service"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( + "ff3514e3-5a33-55df-13ab-12abad84e7ff"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( + "fe6985cd-ea33-3346-ac12-ab121484a3fe"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName( + "parent service model name"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("1.0"); + + relatedInstanceListElement3.getRelatedInstance().setInstanceId("vnfInstanceId"); + relatedInstanceListElement3.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelType("vnf"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelInvariantId( + "ff5256d1-5a33-55df-13ab-12abad84e7ff"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersionId( + "fe6478e4-ea33-3346-ac12-ab121484a3fe"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelName("vSAMP12"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersion("1.0"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelCustomizationName("vSAMP12 1"); + + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement3); + + Map userParam1 = new HashMap<>(); + userParam1.put("name1", "value1"); + + Map userParam2 = new HashMap<>(); + userParam2.put("name2", "value2"); + + request.getRequestDetails().getRequestParameters().getUserParams().add(userParam1); + request.getRequestDetails().getRequestParameters().getUserParams().add(userParam2); + + logger.debug(Serialization.gsonPretty.toJson(request)); + + } + + @Test + public void testHack() { + + logger.debug("** HACK **"); + + SORequest request = new SORequest(); + + request.setRequestDetails(new SORequestDetails()); + request.getRequestDetails().setModelInfo(new SOModelInfo()); + request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); + request.getRequestDetails().setRequestInfo(new SORequestInfo()); + request.getRequestDetails().setRequestParameters(new SORequestParameters()); + request.getRequestDetails().getRequestParameters().setUserParams(null); + + request.getRequestDetails().getModelInfo().setModelType("vfModule"); + request.getRequestDetails().getModelInfo().setModelInvariantId("a9c4a35a-de48-451a-9e4e-343f2ac52928"); + request.getRequestDetails().getModelInfo().setModelVersionId("e0d98ad1-238d-4555-b439-023d3f9079f6"); + request.getRequestDetails().getModelInfo().setModelName("0d9e0d9d352749f4B3cb..dnsscaling..module-0"); + request.getRequestDetails().getModelInfo().setModelVersion("2.0"); + + request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("DFW"); + request.getRequestDetails().getCloudConfiguration().setTenantId("1015548"); + + request.getRequestDetails().getRequestInfo().setInstanceName( + "Vfmodule_Ete_Name1eScaling63928f-ccdc-4b34-bdef-9bf64109026e"); + request.getRequestDetails().getRequestInfo().setSource("POLICY"); + request.getRequestDetails().getRequestInfo().setSuppressRollback(false); + + SORelatedInstanceListElement relatedInstanceListElement1 = + new SORelatedInstanceListElement(); + SORelatedInstanceListElement relatedInstanceListElement2 = + new SORelatedInstanceListElement(); + relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); + + String serviceInstanceId = "98af39ce-6408-466b-921f-c2c7a8f59ed6"; + relatedInstanceListElement1.getRelatedInstance().setInstanceId(serviceInstanceId); + relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelInvariantId( + "24329a0c-1d57-4210-b1af-a65df64e9d59"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersionId( + "ac642881-8e7e-4217-bd64-16ad41c42e30"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName("5116d67e-0b4f-46bf-a46f"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion("2.0"); + + String vnfInstanceId = "8eb411b8-a936-412f-b01f-9a9a435c0e93"; + relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfInstanceId); + relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( + "09fd971e-db5f-475d-997c-cf6704b6b8fe"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( + "152ed917-6dcc-46ee-bf8a-a775c5aa5a74"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName("9e4c31d2-4b25-4d9e-9fb4"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("2.0"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName( + "0d9e0d9d-3527-49f4-b3cb 2"); + + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); + + logger.debug(Serialization.gsonPretty.toJson(request)); + } + +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java new file mode 100755 index 000000000..d6fd0ad25 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.time.LocalDateTime; + +import org.junit.Test; + +public class SoAsyncRequestStatusTest { + + @Test + public void testConstructor() { + SOAsyncRequestStatus obj = new SOAsyncRequestStatus(); + + assertTrue(obj.getCorrelator() == null); + assertTrue(obj.getFinishTime() == null); + assertTrue(obj.getInstanceReferences() == null); + assertTrue(obj.getRequestId() == null); + assertTrue(obj.getRequestScope() == null); + assertTrue(obj.getRequestStatus() == null); + assertTrue(obj.getStartTime() == null); + } + + @Test + public void testSetGet() { + SOAsyncRequestStatus obj = new SOAsyncRequestStatus(); + + obj.setCorrelator("correlator"); + assertEquals("correlator", obj.getCorrelator()); + + LocalDateTime finishTime = LocalDateTime.now(); + obj.setFinishTime(finishTime); + assertEquals(finishTime, obj.getFinishTime()); + + SOInstanceReferences instanceReferences = new SOInstanceReferences(); + obj.setInstanceReferences(instanceReferences); + assertEquals(instanceReferences, obj.getInstanceReferences()); + + obj.setRequestId("requestId"); + assertEquals("requestId", obj.getRequestId()); + + obj.setRequestScope("requestScope"); + assertEquals("requestScope", obj.getRequestScope()); + + SORequestStatus requestStatus = new SORequestStatus(); + obj.setRequestStatus(requestStatus); + assertEquals(requestStatus, obj.getRequestStatus()); + + obj.setRequestType("requestType"); + assertEquals("requestType", obj.getRequestType()); + + LocalDateTime startTime = LocalDateTime.now(); + obj.setStartTime(startTime); + assertEquals(startTime, obj.getStartTime()); + + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java new file mode 100755 index 000000000..8b52ae9a2 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoCloudConfigurationTest { + + @Test + public void testConstructor() { + SOCloudConfiguration obj = new SOCloudConfiguration(); + + assertTrue(obj.getLcpCloudRegionId() == null); + assertTrue(obj.getTenantId() == null); + } + + @Test + public void testSetGet() { + SOCloudConfiguration obj = new SOCloudConfiguration(); + + obj.setLcpCloudRegionId("lcpCloudRegionId"); + assertEquals("lcpCloudRegionId", obj.getLcpCloudRegionId()); + + obj.setTenantId("tenantId"); + assertEquals("tenantId", obj.getTenantId()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java new file mode 100644 index 000000000..17f92bcb9 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java @@ -0,0 +1,239 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Modifications Copyright (C) 2018 AT&T. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import com.google.gson.Gson; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +@Path("/SO") +public class SoDummyServerTest { + + private static int postMessagesReceived = 0; + private static int putMessagesReceived = 0; + private static int statMessagesReceived = 0; + private static int getMessagesReceived = 0; + private static int deleteMessagesReceived = 0; + + private static Map ongoingRequestMap = new ConcurrentHashMap<>(); + + /** + * Stats method. + * + * @return response + */ + @GET + @Path("/Stats") + public Response serviceGetStats() { + statMessagesReceived++; + return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); + + } + + /** + * Get stat type. + * + * @param statType the stat type + * @return http response + */ + @GET + @Path("/OneStat/{statType}") + public Response serviceGetStat(@PathParam("statType") final String statType) { + statMessagesReceived++; + return Response.status(200).entity("{\"TYPE\": " + statType + "}").build(); + } + + /** + * Post to service instantiation. + * + * @param jsonString string to send + * @return http response + */ + @POST + @Path("/serviceInstantiation/v7") + public Response servicePostRequest(final String jsonString) { + postMessagesReceived++; + return buildResponse(jsonString); + } + + /** + * Post. + * + * @param serviceInstanceId service instance id + * @param vnfInstanceId vnf instance id + * @param jsonString json body + * @return http response + */ + @POST + @Path("/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") + public Response servicePostRequestVfModules(@PathParam("serviceInstanceId") final String serviceInstanceId, + @PathParam("vnfInstanceId") final String vnfInstanceId, final String jsonString) { + postMessagesReceived++; + return buildResponse(jsonString); + } + + /** + * Get instance ID. + * + * @param nsInstanceId node instance id + * @return http response + */ + @GET + @Path("/orchestrationRequests/v5/{nsInstanceId}") + public Response soRequestStatus(@PathParam("nsInstanceId") final String nsInstanceId) { + + SOResponse response = ongoingRequestMap.get(nsInstanceId); + + int iterationsLeft = Integer.valueOf(response.getRequest().getRequestScope()); + if (--iterationsLeft > 0) { + response.getRequest().setRequestScope(new Integer(iterationsLeft).toString()); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()).entity(responseString).build(); + } + + ongoingRequestMap.remove(nsInstanceId); + + if ("ReturnBadAfterWait".equals(response.getRequest().getRequestType())) { + return Response.status(400).build(); + } + + response.getRequest().getRequestStatus().setRequestState("COMPLETE"); + response.getRequest().setRequestScope("0"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()).entity(responseString).build(); + } + + /** + * Delete. + * + * @param serviceInstanceId service instance id + * @param vnfInstanceId vnf instance id + * @param vfModuleInstanceId vf module instance id + * @param jsonString json body + * @return http response + */ + @DELETE + @Path("/serviceInstances/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleInstanceId}") + public Response serviceDeleteRequestVfModules( + @PathParam("serviceInstanceId") final String serviceInstanceId, + @PathParam("vnfInstanceId") final String vnfInstanceId, + @PathParam("vfModuleInstanceId") final String vfModuleInstanceId, + final String jsonString) { + deleteMessagesReceived++; + return buildResponse(jsonString); + } + + private Response buildResponse(String jsonString) { + if (jsonString == null) { + return Response.status(400).build(); + } + + SORequest request = null; + try { + request = new Gson().fromJson(jsonString, SORequest.class); + } catch (Exception e) { + return Response.status(400).build(); + } + + if (request == null) { + return Response.status(400).build(); + } + + if (request.getRequestType() == null) { + return Response.status(400).build(); + } + + if ("ReturnBadJson".equals(request.getRequestType())) { + return Response.status(200) + .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\":" + " , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); + } + + SOResponse response = new SOResponse(); + response.setRequest(request); + response.setRequestReferences(new SORequestReferences()); + response.getRequestReferences().setRequestId(request.getRequestId().toString()); + + if ("ReturnCompleted".equals(request.getRequestType())) { + response.getRequest().getRequestStatus().setRequestState("COMPLETE"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + + if ("ReturnFailed".equals(request.getRequestType())) { + response.getRequest().getRequestStatus().setRequestState("FAILED"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + + if ("ReturnOnging202".equals(request.getRequestType())) { + ongoingRequestMap.put(request.getRequestId().toString(), response); + + response.getRequest().getRequestStatus().setRequestState("ONGOING"); + response.setHttpResponseCode(202); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + + if ("ReturnOnging200".equals(request.getRequestType())) { + ongoingRequestMap.put(request.getRequestId().toString(), response); + + response.getRequest().getRequestStatus().setRequestState("ONGOING"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + + if ("ReturnBadAfterWait".equals(request.getRequestType())) { + ongoingRequestMap.put(request.getRequestId().toString(), response); + + response.getRequest().getRequestStatus().setRequestState("ONGOING"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + return null; + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java new file mode 100755 index 000000000..39e37f0cb --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoInstanceReferencesTest { + + @Test + public void testConstructor() { + SOInstanceReferences obj = new SOInstanceReferences(); + + assertTrue(obj.getInstanceId() == null); + assertTrue(obj.getRequestId() == null); + } + + @Test + public void testSetGet() { + SOInstanceReferences obj = new SOInstanceReferences(); + + obj.setInstanceId("instanceId"); + assertEquals("instanceId", obj.getInstanceId()); + + obj.setRequestId("requestId"); + assertEquals("requestId", obj.getRequestId()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java new file mode 100644 index 000000000..c090513f6 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java @@ -0,0 +1,404 @@ +/*- + * ============LICENSE_START======================================================= + * TestSOManager + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.net.URI; +import java.util.UUID; +import java.util.concurrent.Future; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.drools.core.WorkingMemory; +import org.glassfish.grizzly.http.server.HttpServer; +import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; +import org.glassfish.jersey.server.ResourceConfig; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.drools.system.PolicyEngine; + +public class SoManagerTest { + private static final String BASE_URI = "http://localhost:46553/TestSOManager"; + private static final String BASE_SO_URI = BASE_URI + "/SO"; + private static HttpServer server; + + /** + * Set up test class. + */ + @BeforeClass + public static void setUp() throws IOException { + final ResourceConfig rc = new ResourceConfig(SoDummyServerTest.class); + //Grizzly by default doesn't allow payload for HTTP methods (ex: DELETE), for which HTTP spec doesn't + // explicitly state that. + //allow it before starting the server + server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc, false); + server.getServerConfiguration().setAllowPayloadForUndefinedHttpMethods(true); + server.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + server.shutdown(); + } + + @Test + public void testGrizzlyServer() throws ClientProtocolException, IOException { + CloseableHttpClient httpclient = HttpClients.createDefault(); + HttpGet httpGet = new HttpGet("http://localhost:46553/TestSOManager/SO/Stats"); + CloseableHttpResponse response = httpclient.execute(httpGet); + + String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8"); + assertTrue(returnBody.matches("^\\{\"GET\": [0-9]*,\"STAT\": [0-9]*,\"POST\": [0-9]*,\"PUT\": [0-9]*," + + "\"DELETE\": [0-9]*\\}$")); + } + + @Test + public void testServiceInstantiation() throws IOException { + SOManager manager = new SOManager(); + assertNotNull(manager); + manager.setRestGetTimeout(100); + + SOResponse response = manager.createModuleInstance("http:/localhost:99999999", BASE_SO_URI, "sean", + "citizen", null); + assertNull(response); + + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", null); + assertNull(response); + + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", new SORequest()); + assertNull(response); + + SORequest request = new SORequest(); + request.setRequestId(UUID.randomUUID()); + request.setRequestScope("Test"); + request.setRequestType("ReturnBadJson"); + request.setStartTime("2018-03-23 16:31"); + request.setRequestStatus(new SORequestStatus()); + request.getRequestStatus().setRequestState("ONGOING"); + + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNull(response); + + request.setRequestType("ReturnCompleted"); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNotNull(response); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + + request.setRequestType("ReturnFailed"); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNotNull(response); + assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); + + // Use scope to set the number of iterations we'll wait for + + request.setRequestType("ReturnOnging200"); + request.setRequestScope(new Integer(10).toString()); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNotNull(response); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(20).toString()); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNotNull(response); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + + // Test timeout after 20 attempts for a response + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(21).toString()); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNull(response); + + // Test bad response after 3 attempts for a response + request.setRequestType("ReturnBadAfterWait"); + request.setRequestScope(new Integer(3).toString()); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNull(response); + } + + @Test + public void testVfModuleCreation() throws IOException { + SOManager manager = new SOManager(); + assertNotNull(manager); + manager.setRestGetTimeout(100); + + PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); + PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); + + WorkingMemory wm = new DummyWorkingMemory(); + + SORequest soRequest = new SORequest(); + soRequest.setOperationType(SoOperationType.SCALE_OUT); + PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); + Future asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, + UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), soRequest); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + SORequest request = new SORequest(); + request.setRequestId(UUID.randomUUID()); + request.setRequestScope("Test"); + request.setRequestType("ReturnBadJson"); + request.setStartTime("2018-03-23 16:31"); + request.setRequestStatus(new SORequestStatus()); + request.getRequestStatus().setRequestState("ONGOING"); + request.setOperationType(SoOperationType.SCALE_OUT); + + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnCompleted"); + + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnFailed"); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Use scope to set the number of iterations we'll wait for + + request.setRequestType("ReturnOnging200"); + request.setRequestScope(new Integer(10).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(20).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Test timeout after 20 attempts for a response + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(21).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Test bad response after 3 attempts for a response + request.setRequestType("ReturnBadAfterWait"); + request.setRequestScope(new Integer(3).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + } + + @Test + public void testVfModuleDeletion() { + SOManager manager = new SOManager(); + assertNotNull(manager); + manager.setRestGetTimeout(100); + + PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); + PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); + + WorkingMemory wm = new DummyWorkingMemory(); + + SORequest soRequest = new SORequest(); + soRequest.setOperationType(SoOperationType.DELETE_VF_MODULE); + PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); + Future asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, + UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + SORequest request = new SORequest(); + request.setRequestId(UUID.randomUUID()); + request.setRequestScope("Test"); + request.setRequestType("ReturnBadJson"); + request.setStartTime("2018-03-23 16:31"); + request.setRequestStatus(new SORequestStatus()); + request.getRequestStatus().setRequestState("ONGOING"); + request.setOperationType(SoOperationType.DELETE_VF_MODULE); + + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnCompleted"); + + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnFailed"); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Use scope to set the number of iterations we'll wait for + + request.setRequestType("ReturnOnging200"); + request.setRequestScope(new Integer(10).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(20).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Test timeout after 20 attempts for a response + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(21).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Test bad response after 3 attempts for a response + request.setRequestType("ReturnBadAfterWait"); + request.setRequestScope(new Integer(3).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java new file mode 100755 index 000000000..5898f04f0 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoModelInfoTest { + + @Test + public void testConstructor() { + SOModelInfo obj = new SOModelInfo(); + + assertTrue(obj.getModelCustomizationId() == null); + assertTrue(obj.getModelCustomizationName() == null); + assertTrue(obj.getModelInvariantId() == null); + assertTrue(obj.getModelName() == null); + assertTrue(obj.getModelType() == null); + assertTrue(obj.getModelVersion() == null); + assertTrue(obj.getModelVersionId() == null); + } + + @Test + public void testSetGet() { + SOModelInfo obj = new SOModelInfo(); + + obj.setModelCustomizationId("modelCustomizationId"); + assertEquals("modelCustomizationId", obj.getModelCustomizationId()); + + obj.setModelCustomizationName("modelCustomizationName"); + assertEquals("modelCustomizationName", obj.getModelCustomizationName()); + + obj.setModelInvariantId("modelInvariantId"); + assertEquals("modelInvariantId", obj.getModelInvariantId()); + + obj.setModelName("modelName"); + assertEquals("modelName", obj.getModelName()); + + obj.setModelType("modelType"); + assertEquals("modelType", obj.getModelType()); + + obj.setModelVersion("modelVersion"); + assertEquals("modelVersion", obj.getModelVersion()); + + obj.setModelVersionId("modelVersionId"); + assertEquals("modelVersionId", obj.getModelVersionId()); + + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java new file mode 100755 index 000000000..2dea68d8f --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoPolicyExceptionHolderTest { + + @Test + public void testConstructor() { + SOPolicyExceptionHolder obj = new SOPolicyExceptionHolder(); + + assertTrue(obj.getMessageId() == null); + assertTrue(obj.getText() == null); + } + + @Test + public void testSetGet() { + SOPolicyExceptionHolder obj = new SOPolicyExceptionHolder(); + + obj.setMessageId("messageId"); + assertEquals("messageId", obj.getMessageId()); + + obj.setText("text"); + assertEquals("text", obj.getText()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java new file mode 100755 index 000000000..4c549361a --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRelatedInstanceListElementTest { + + @Test + public void testConstructor() { + SORelatedInstanceListElement obj = new SORelatedInstanceListElement(); + + assertTrue(obj.getRelatedInstance() == null); + } + + @Test + public void testSetGet() { + SORelatedInstanceListElement obj = new SORelatedInstanceListElement(); + + SORelatedInstance relatedInstance = new SORelatedInstance(); + obj.setRelatedInstance(relatedInstance); + assertEquals(relatedInstance, obj.getRelatedInstance()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java new file mode 100755 index 000000000..aa137e19f --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRelatedInstanceTest { + + @Test + public void testConstructor() { + SORelatedInstance obj = new SORelatedInstance(); + + assertTrue(obj.getInstanceId() == null); + assertTrue(obj.getInstanceName() == null); + assertTrue(obj.getModelInfo() == null); + } + + @Test + public void testSetGet() { + SORelatedInstance obj = new SORelatedInstance(); + + obj.setInstanceId("instanceId"); + assertEquals("instanceId", obj.getInstanceId()); + + obj.setInstanceName("instanceName"); + assertEquals("instanceName", obj.getInstanceName()); + + SOModelInfo modelInfo = new SOModelInfo(); + obj.setModelInfo(modelInfo); + assertEquals(modelInfo, obj.getModelInfo()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java new file mode 100755 index 000000000..71ae7ca66 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class SoRequestDetailsTest { + + @Test + public void testConstructor() { + SORequestDetails obj = new SORequestDetails(); + + assertTrue(obj.getCloudConfiguration() == null); + assertTrue(obj.getModelInfo() == null); + assertTrue(obj.getRequestInfo() == null); + assertTrue(obj.getRequestParameters() == null); + assertTrue(obj.getSubscriberInfo() == null); + + assertTrue(obj.getRelatedInstanceList() != null); + assertEquals(0, obj.getRelatedInstanceList().size()); + } + + @Test + public void testSetGet() { + SORequestDetails obj = new SORequestDetails(); + + SOCloudConfiguration cloudConfiguration = new SOCloudConfiguration(); + obj.setCloudConfiguration(cloudConfiguration); + assertEquals(cloudConfiguration, obj.getCloudConfiguration()); + + SOModelInfo modelInfo = new SOModelInfo(); + obj.setModelInfo(modelInfo); + assertEquals(modelInfo, obj.getModelInfo()); + + SORequestInfo requestInfo = new SORequestInfo(); + obj.setRequestInfo(requestInfo); + assertEquals(requestInfo, obj.getRequestInfo()); + + SORequestParameters requestParameters = new SORequestParameters(); + obj.setRequestParameters(requestParameters); + assertEquals(requestParameters, obj.getRequestParameters()); + + SOSubscriberInfo subscriberInfo = new SOSubscriberInfo(); + obj.setSubscriberInfo(subscriberInfo); + assertEquals(subscriberInfo, obj.getSubscriberInfo()); + } + + @Test + public void testSoMRequestDetailsMethods() { + SORequestDetails details = new SORequestDetails(); + assertNotNull(details); + assertNotEquals(0, details.hashCode()); + + SOCloudConfiguration cloudConfiguration = new SOCloudConfiguration(); + details.setCloudConfiguration(cloudConfiguration); + assertEquals(cloudConfiguration, details.getCloudConfiguration()); + assertNotEquals(0, details.hashCode()); + + SOModelInfo modelInfo = new SOModelInfo(); + details.setModelInfo(modelInfo); + assertEquals(modelInfo, details.getModelInfo()); + assertNotEquals(0, details.hashCode()); + + List relatedInstanceList = new ArrayList<>(); + details.setRelatedInstanceList(relatedInstanceList); + assertEquals(relatedInstanceList, details.getRelatedInstanceList()); + assertNotEquals(0, details.hashCode()); + + SORequestInfo requestInfo = new SORequestInfo(); + details.setRequestInfo(requestInfo); + assertEquals(requestInfo, details.getRequestInfo()); + assertNotEquals(0, details.hashCode()); + + SORequestParameters requestParameters = new SORequestParameters(); + details.setRequestParameters(requestParameters); + assertEquals(requestParameters, details.getRequestParameters()); + assertNotEquals(0, details.hashCode()); + + SOSubscriberInfo subscriberInfo = new SOSubscriberInfo(); + details.setSubscriberInfo(subscriberInfo); + assertEquals(subscriberInfo, details.getSubscriberInfo()); + assertNotEquals(0, details.hashCode()); + + assertEquals("SORequestDetails [modelInfo=org.onap.policy.so", details.toString().substring(0, 46)); + + SORequestDetails copiedDetails = new SORequestDetails(details); + + assertTrue(details.equals(details)); + assertTrue(details.equals(copiedDetails)); + assertFalse(details.equals(null)); + assertFalse(details.equals("Hello")); + + details.setCloudConfiguration(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setCloudConfiguration(null); + assertTrue(details.equals(copiedDetails)); + details.setCloudConfiguration(cloudConfiguration); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setCloudConfiguration(cloudConfiguration); + assertTrue(details.equals(copiedDetails)); + + details.setModelInfo(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setModelInfo(null); + assertTrue(details.equals(copiedDetails)); + details.setModelInfo(modelInfo); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setModelInfo(modelInfo); + assertTrue(details.equals(copiedDetails)); + + details.setRequestInfo(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRequestInfo(null); + assertTrue(details.equals(copiedDetails)); + details.setRequestInfo(requestInfo); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRequestInfo(requestInfo); + assertTrue(details.equals(copiedDetails)); + + details.setRequestParameters(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRequestParameters(null); + assertTrue(details.equals(copiedDetails)); + details.setRequestParameters(requestParameters); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRequestParameters(requestParameters); + assertTrue(details.equals(copiedDetails)); + + details.setSubscriberInfo(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setSubscriberInfo(null); + assertTrue(details.equals(copiedDetails)); + details.setSubscriberInfo(subscriberInfo); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setSubscriberInfo(subscriberInfo); + assertTrue(details.equals(copiedDetails)); + + details.setRelatedInstanceList(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRelatedInstanceList(null); + assertTrue(details.equals(copiedDetails)); + details.setRelatedInstanceList(relatedInstanceList); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRelatedInstanceList(relatedInstanceList); + assertTrue(details.equals(copiedDetails)); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java new file mode 100755 index 000000000..f700fbc70 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestErrorTest { + + @Test + public void testConstructor() { + SORequestError obj = new SORequestError(); + + assertTrue(obj.getPolicyException() == null); + assertTrue(obj.getServiceException() == null); + } + + @Test + public void testSetGet() { + SORequestError obj = new SORequestError(); + + SOPolicyExceptionHolder policyException = new SOPolicyExceptionHolder(); + obj.setPolicyException(policyException); + assertEquals(policyException, obj.getPolicyException()); + + SOServiceExceptionHolder serviceException = new SOServiceExceptionHolder(); + obj.setServiceException(serviceException); + assertEquals(serviceException, obj.getServiceException()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java new file mode 100755 index 000000000..c09da54dc --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestInfoTest { + + @Test + public void testConstructor() { + SORequestInfo obj = new SORequestInfo(); + + assertTrue(obj.getBillingAccountNumber() == null); + assertTrue(obj.getCallbackUrl() == null); + assertTrue(obj.getCorrelator() == null); + assertTrue(obj.getInstanceName() == null); + assertTrue(obj.getOrderNumber() == null); + assertTrue(obj.getOrderVersion() == null); + assertTrue(obj.getProductFamilyId() == null); + assertTrue(obj.getRequestorId() == null); + assertTrue(obj.getSource() == null); + assertTrue(obj.isSuppressRollback() == false); + } + + @Test + public void testSetGet() { + SORequestInfo obj = new SORequestInfo(); + + obj.setBillingAccountNumber("billingAccountNumber"); + assertEquals("billingAccountNumber", obj.getBillingAccountNumber()); + + obj.setCallbackUrl("callbackUrl"); + assertEquals("callbackUrl", obj.getCallbackUrl()); + + obj.setCorrelator("correlator"); + assertEquals("correlator", obj.getCorrelator()); + + obj.setInstanceName("instanceName"); + assertEquals("instanceName", obj.getInstanceName()); + + obj.setOrderNumber("orderNumber"); + assertEquals("orderNumber", obj.getOrderNumber()); + + int orderVersion = 2008; + obj.setOrderVersion(orderVersion); + assertEquals((Integer) orderVersion, obj.getOrderVersion()); + + obj.setProductFamilyId("productFamilyId"); + assertEquals("productFamilyId", obj.getProductFamilyId()); + + obj.setRequestorId("requestorId"); + assertEquals("requestorId", obj.getRequestorId()); + + obj.setSource("source"); + assertEquals("source", obj.getSource()); + + obj.setSuppressRollback(true); + assertEquals(true, obj.isSuppressRollback()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java new file mode 100755 index 000000000..db93988c9 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestParametersTest { + + @Test + public void testConstructor() { + SORequestParameters obj = new SORequestParameters(); + + assertTrue(obj.getSubscriptionServiceType() == null); + assertTrue(obj.getUserParams() != null); + assertEquals(0, obj.getUserParams().size()); + } + + @Test + public void testSetGet() { + SORequestParameters obj = new SORequestParameters(); + + obj.setSubscriptionServiceType("subscriptionServiceType"); + assertEquals("subscriptionServiceType", obj.getSubscriptionServiceType()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java new file mode 100755 index 000000000..5d6ff2090 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestReferencesTest { + + @Test + public void testConstructor() { + SORequestReferences obj = new SORequestReferences(); + + assertTrue(obj.getInstanceId() == null); + assertTrue(obj.getRequestId() == null); + } + + @Test + public void testSetGet() { + SORequestReferences obj = new SORequestReferences(); + + obj.setInstanceId("instanceId"); + assertEquals("instanceId", obj.getInstanceId()); + + obj.setRequestId("requestId"); + assertEquals("requestId", obj.getRequestId()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java new file mode 100755 index 000000000..cd3e1b58a --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestStatusTest { + + @Test + public void testConstructor() { + SORequestStatus obj = new SORequestStatus(); + + assertEquals(0, obj.getPercentProgress()); + assertTrue(obj.getRequestState() == null); + assertTrue(obj.getTimestamp() == null); + assertFalse(obj.isWasRolledBack()); + } + + @Test + public void testSetGet() { + SORequestStatus obj = new SORequestStatus(); + + obj.setPercentProgress(2008); + assertEquals(2008, obj.getPercentProgress()); + + obj.setRequestState("requestState"); + assertEquals("requestState", obj.getRequestState()); + + obj.setTimestamp("timestamp"); + assertEquals("timestamp", obj.getTimestamp()); + + obj.setWasRolledBack(true); + assertTrue(obj.isWasRolledBack()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java new file mode 100755 index 000000000..c09c58471 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.time.LocalDateTime; +import java.util.UUID; + +import org.junit.Test; + +public class SoRequestTest { + + @Test + public void testConstructor() { + SORequest obj = new SORequest(); + + assertTrue(obj.getFinishTime() == null); + assertTrue(obj.getRequestDetails() == null); + assertTrue(obj.getRequestId() == null); + assertTrue(obj.getRequestScope() == null); + assertTrue(obj.getRequestStatus() == null); + assertTrue(obj.getRequestType() == null); + assertTrue(obj.getStartTime() == null); + } + + @Test + public void testSetGet() { + SORequest obj = new SORequest(); + + LocalDateTime finishTime = LocalDateTime.now(); + obj.setFinishTime(finishTime); + assertEquals(finishTime, obj.getFinishTime()); + + UUID uuid = UUID.randomUUID(); + obj.setRequestId(uuid); + assertEquals(uuid, obj.getRequestId()); + + obj.setRequestScope("requestScope"); + assertEquals("requestScope", obj.getRequestScope()); + + SORequestStatus requestStatus = new SORequestStatus(); + obj.setRequestStatus(requestStatus); + assertEquals(requestStatus, obj.getRequestStatus()); + + obj.setRequestType("requestType"); + assertEquals("requestType", obj.getRequestType()); + + obj.setOperationType(SoOperationType.DELETE_VF_MODULE); + assertEquals(SoOperationType.DELETE_VF_MODULE, obj.getOperationType()); + + LocalDateTime startTime = LocalDateTime.now(); + obj.setStartTime(startTime.toString()); + assertEquals(startTime.toString(), obj.getStartTime()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java new file mode 100755 index 000000000..cf396561b --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoResponseTest { + + @Test + public void testConstructor() { + SOResponse obj = new SOResponse(); + + assertEquals(0, obj.getHttpResponseCode()); + assertTrue(obj.getRequest() == null); + assertTrue(obj.getRequestError() == null); + assertTrue(obj.getRequestReferences() == null); + } + + @Test + public void testSetGet() { + SOResponse obj = new SOResponse(); + + obj.setHttpResponseCode(2008); + assertEquals(2008, obj.getHttpResponseCode()); + + SORequest request = new SORequest(); + obj.setRequest(request); + assertEquals(request, obj.getRequest()); + + SORequestError requestError = new SORequestError(); + obj.setRequestError(requestError); + assertEquals(requestError, obj.getRequestError()); + + SORequestReferences requestReferences = new SORequestReferences(); + obj.setRequestReferences(requestReferences); + assertEquals(requestReferences, obj.getRequestReferences()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java new file mode 100755 index 000000000..181fe2138 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.UUID; + +import org.junit.Test; + +public class SoResponseWrapperTest { + + @Test + public void testConstructor() { + SOResponse response = new SOResponse(); + SOResponseWrapper obj = new SOResponseWrapper(response, "reqID"); + + assertEquals(response, obj.getSoResponse()); + assertEquals("reqID", obj.getRequestID()); + } + + @Test + public void testSetGet() { + SOResponse response = new SOResponse(); + SOResponseWrapper obj = new SOResponseWrapper(response, "reqID"); + + SOResponse response2 = new SOResponse(); + response2.setHttpResponseCode(2008); + obj.setSoResponse(response2); + assertEquals(response2, obj.getSoResponse()); + + obj.setRequestID("id2"); + assertEquals("id2", obj.getRequestID()); + } + + @Test + public void testSoResponseWrapperMethods() { + String requestId = UUID.randomUUID().toString(); + SOResponse response = new SOResponse(); + + SOResponseWrapper responseWrapper = new SOResponseWrapper(response, requestId); + assertNotNull(responseWrapper); + assertNotEquals(0, responseWrapper.hashCode()); + + assertEquals(response, responseWrapper.getSoResponse()); + + assertNotEquals(0, responseWrapper.hashCode()); + + assertEquals("SOResponseWrapper [SOResponse=org.onap.policy.", responseWrapper.toString().substring(0, 46)); + + SOResponseWrapper identicalResponseWrapper = new SOResponseWrapper(response, requestId); + + assertEquals(responseWrapper, responseWrapper); + assertEquals(responseWrapper, identicalResponseWrapper); + assertNotEquals(null, responseWrapper); + assertNotEquals("Hello", responseWrapper); + assertFalse(responseWrapper.equals(null)); + assertFalse(responseWrapper.equals("AString")); + + assertEquals(new SOResponseWrapper(null, null), new SOResponseWrapper(null, null)); + assertNotEquals(new SOResponseWrapper(null, null), identicalResponseWrapper); + + assertNotEquals(0, new SOResponseWrapper(null, null).hashCode()); + + identicalResponseWrapper.setSoResponse(new SOResponse()); + assertNotEquals(responseWrapper, identicalResponseWrapper); + identicalResponseWrapper.setSoResponse(response); + assertEquals(responseWrapper, identicalResponseWrapper); + + identicalResponseWrapper.setRequestID(UUID.randomUUID().toString()); + assertNotEquals(responseWrapper, identicalResponseWrapper); + identicalResponseWrapper.setRequestID(requestId); + assertEquals(responseWrapper, identicalResponseWrapper); + + responseWrapper.setRequestID(null); + assertNotEquals(responseWrapper, identicalResponseWrapper); + identicalResponseWrapper.setRequestID(null); + assertEquals(responseWrapper, identicalResponseWrapper); + responseWrapper.setRequestID(requestId); + assertNotEquals(responseWrapper, identicalResponseWrapper); + identicalResponseWrapper.setRequestID(requestId); + assertEquals(responseWrapper, identicalResponseWrapper); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java new file mode 100755 index 000000000..b0ce56652 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoServiceExceptionHolderTest { + + @Test + public void testConstructor() { + SOServiceExceptionHolder obj = new SOServiceExceptionHolder(); + + assertTrue(obj.getMessageId() == null); + assertTrue(obj.getText() == null); + assertTrue(obj.getVariables() != null); + assertEquals(0, obj.getVariables().size()); + } + + @Test + public void testSetGet() { + SOServiceExceptionHolder obj = new SOServiceExceptionHolder(); + + obj.setMessageId("messageId"); + assertEquals("messageId", obj.getMessageId()); + + obj.setText("text"); + assertEquals("text", obj.getText()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java new file mode 100755 index 000000000..ea38bd597 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoSubscriberInfoTest { + + @Test + public void testConstructor() { + SOSubscriberInfo obj = new SOSubscriberInfo(); + + assertTrue(obj.getGlobalSubscriberId() == null); + assertTrue(obj.getSubscriberCommonSiteId() == null); + assertTrue(obj.getSubscriberName() == null); + } + + @Test + public void testSetGet() { + SOSubscriberInfo obj = new SOSubscriberInfo(); + + obj.setGlobalSubscriberId("globalSubscriberId"); + assertEquals("globalSubscriberId", obj.getGlobalSubscriberId()); + + obj.setSubscriberCommonSiteId("subscriberCommonSiteId"); + assertEquals("subscriberCommonSiteId", obj.getSubscriberCommonSiteId()); + + obj.setSubscriberName("subscriberName"); + assertEquals("subscriberName", obj.getSubscriberName()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java deleted file mode 100644 index 1b2cb697a..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * mso - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.onap.policy.so.SOCloudConfiguration; -import org.onap.policy.so.SOModelInfo; -import org.onap.policy.so.SORelatedInstance; -import org.onap.policy.so.SORelatedInstanceListElement; -import org.onap.policy.so.SORequest; -import org.onap.policy.so.SORequestDetails; -import org.onap.policy.so.SORequestInfo; -import org.onap.policy.so.SORequestParameters; -import org.onap.policy.so.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestDemo { - private static final Logger logger = LoggerFactory.getLogger(TestDemo.class); - - @Test - public void test() { - - SORequest request = new SORequest(); - request.setRequestDetails(new SORequestDetails()); - request.getRequestDetails().setModelInfo(new SOModelInfo()); - request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); - request.getRequestDetails().setRequestInfo(new SORequestInfo()); - request.getRequestDetails().setRequestParameters(new SORequestParameters()); - - request.getRequestDetails().getModelInfo().setModelType("vfModule"); - request.getRequestDetails().getModelInfo().setModelInvariantId("ff5256d2-5a33-55df-13ab-12abad84e7ff"); - request.getRequestDetails().getModelInfo().setModelVersionId("fe6478e5-ea33-3346-ac12-ab121484a3fe"); - request.getRequestDetails().getModelInfo().setModelName("vSAMP12..base..module-0"); - request.getRequestDetails().getModelInfo().setModelVersion("1"); - - request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("mdt1"); - request.getRequestDetails().getCloudConfiguration().setTenantId("88a6ca3ee0394ade9403f075db23167e"); - - request.getRequestDetails().getRequestInfo().setInstanceName("SOTEST103a-vSAMP12_base_module-0"); - request.getRequestDetails().getRequestInfo().setSource("VID"); - request.getRequestDetails().getRequestInfo().setSuppressRollback(true); - - SORelatedInstanceListElement relatedInstanceListElement1 = - new SORelatedInstanceListElement(); - SORelatedInstanceListElement relatedInstanceListElement2 = - new SORelatedInstanceListElement(); - SORelatedInstanceListElement relatedInstanceListElement3 = - new SORelatedInstanceListElement(); - relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); - relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); - relatedInstanceListElement3.setRelatedInstance(new SORelatedInstance()); - - relatedInstanceListElement1.getRelatedInstance().setInstanceId( - "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c"); - relatedInstanceListElement1.getRelatedInstance().setInstanceName( - "SOTESTVOL103a-vSAMP12_base_module-0_vol"); - relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("volumeGroup"); - - relatedInstanceListElement2.getRelatedInstance().setInstanceId("serviceInstanceId"); - relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("service"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( - "ff3514e3-5a33-55df-13ab-12abad84e7ff"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( - "fe6985cd-ea33-3346-ac12-ab121484a3fe"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName( - "parent service model name"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("1.0"); - - relatedInstanceListElement3.getRelatedInstance().setInstanceId("vnfInstanceId"); - relatedInstanceListElement3.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelType("vnf"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelInvariantId( - "ff5256d1-5a33-55df-13ab-12abad84e7ff"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersionId( - "fe6478e4-ea33-3346-ac12-ab121484a3fe"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelName("vSAMP12"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersion("1.0"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelCustomizationName("vSAMP12 1"); - - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement3); - - Map userParam1 = new HashMap<>(); - userParam1.put("name1", "value1"); - - Map userParam2 = new HashMap<>(); - userParam2.put("name2", "value2"); - - request.getRequestDetails().getRequestParameters().getUserParams().add(userParam1); - request.getRequestDetails().getRequestParameters().getUserParams().add(userParam2); - - logger.debug(Serialization.gsonPretty.toJson(request)); - - } - - @Test - public void testHack() { - - logger.debug("** HACK **"); - - SORequest request = new SORequest(); - - request.setRequestDetails(new SORequestDetails()); - request.getRequestDetails().setModelInfo(new SOModelInfo()); - request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); - request.getRequestDetails().setRequestInfo(new SORequestInfo()); - request.getRequestDetails().setRequestParameters(new SORequestParameters()); - request.getRequestDetails().getRequestParameters().setUserParams(null); - - request.getRequestDetails().getModelInfo().setModelType("vfModule"); - request.getRequestDetails().getModelInfo().setModelInvariantId("a9c4a35a-de48-451a-9e4e-343f2ac52928"); - request.getRequestDetails().getModelInfo().setModelVersionId("e0d98ad1-238d-4555-b439-023d3f9079f6"); - request.getRequestDetails().getModelInfo().setModelName("0d9e0d9d352749f4B3cb..dnsscaling..module-0"); - request.getRequestDetails().getModelInfo().setModelVersion("2.0"); - - request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("DFW"); - request.getRequestDetails().getCloudConfiguration().setTenantId("1015548"); - - request.getRequestDetails().getRequestInfo().setInstanceName( - "Vfmodule_Ete_Name1eScaling63928f-ccdc-4b34-bdef-9bf64109026e"); - request.getRequestDetails().getRequestInfo().setSource("POLICY"); - request.getRequestDetails().getRequestInfo().setSuppressRollback(false); - - SORelatedInstanceListElement relatedInstanceListElement1 = - new SORelatedInstanceListElement(); - SORelatedInstanceListElement relatedInstanceListElement2 = - new SORelatedInstanceListElement(); - relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); - relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); - - String serviceInstanceId = "98af39ce-6408-466b-921f-c2c7a8f59ed6"; - relatedInstanceListElement1.getRelatedInstance().setInstanceId(serviceInstanceId); - relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelInvariantId( - "24329a0c-1d57-4210-b1af-a65df64e9d59"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersionId( - "ac642881-8e7e-4217-bd64-16ad41c42e30"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName("5116d67e-0b4f-46bf-a46f"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion("2.0"); - - String vnfInstanceId = "8eb411b8-a936-412f-b01f-9a9a435c0e93"; - relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfInstanceId); - relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( - "09fd971e-db5f-475d-997c-cf6704b6b8fe"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( - "152ed917-6dcc-46ee-bf8a-a775c5aa5a74"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName("9e4c31d2-4b25-4d9e-9fb4"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("2.0"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName( - "0d9e0d9d-3527-49f4-b3cb 2"); - - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); - - logger.debug(Serialization.gsonPretty.toJson(request)); - } - -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java deleted file mode 100755 index 7c50ea097..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.LocalDateTime; - -import org.junit.Test; - -public class TestSoAsyncRequestStatus { - - @Test - public void testConstructor() { - SOAsyncRequestStatus obj = new SOAsyncRequestStatus(); - - assertTrue(obj.getCorrelator() == null); - assertTrue(obj.getFinishTime() == null); - assertTrue(obj.getInstanceReferences() == null); - assertTrue(obj.getRequestId() == null); - assertTrue(obj.getRequestScope() == null); - assertTrue(obj.getRequestStatus() == null); - assertTrue(obj.getStartTime() == null); - } - - @Test - public void testSetGet() { - SOAsyncRequestStatus obj = new SOAsyncRequestStatus(); - - obj.setCorrelator("correlator"); - assertEquals("correlator", obj.getCorrelator()); - - LocalDateTime finishTime = LocalDateTime.now(); - obj.setFinishTime(finishTime); - assertEquals(finishTime, obj.getFinishTime()); - - SOInstanceReferences instanceReferences = new SOInstanceReferences(); - obj.setInstanceReferences(instanceReferences); - assertEquals(instanceReferences, obj.getInstanceReferences()); - - obj.setRequestId("requestId"); - assertEquals("requestId", obj.getRequestId()); - - obj.setRequestScope("requestScope"); - assertEquals("requestScope", obj.getRequestScope()); - - SORequestStatus requestStatus = new SORequestStatus(); - obj.setRequestStatus(requestStatus); - assertEquals(requestStatus, obj.getRequestStatus()); - - obj.setRequestType("requestType"); - assertEquals("requestType", obj.getRequestType()); - - LocalDateTime startTime = LocalDateTime.now(); - obj.setStartTime(startTime); - assertEquals(startTime, obj.getStartTime()); - - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java deleted file mode 100755 index bab8970bb..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoCloudConfiguration { - - @Test - public void testConstructor() { - SOCloudConfiguration obj = new SOCloudConfiguration(); - - assertTrue(obj.getLcpCloudRegionId() == null); - assertTrue(obj.getTenantId() == null); - } - - @Test - public void testSetGet() { - SOCloudConfiguration obj = new SOCloudConfiguration(); - - obj.setLcpCloudRegionId("lcpCloudRegionId"); - assertEquals("lcpCloudRegionId", obj.getLcpCloudRegionId()); - - obj.setTenantId("tenantId"); - assertEquals("tenantId", obj.getTenantId()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java deleted file mode 100644 index 2a352b0bf..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 AT&T. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import com.google.gson.Gson; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; - -@Path("/SO") -public class TestSoDummyServer { - - private static int postMessagesReceived = 0; - private static int putMessagesReceived = 0; - private static int statMessagesReceived = 0; - private static int getMessagesReceived = 0; - private static int deleteMessagesReceived = 0; - - private static Map ongoingRequestMap = new ConcurrentHashMap<>(); - - /** - * Stats method. - * - * @return response - */ - @GET - @Path("/Stats") - public Response serviceGetStats() { - statMessagesReceived++; - return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived - + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); - - } - - /** - * Get stat type. - * - * @param statType the stat type - * @return http response - */ - @GET - @Path("/OneStat/{statType}") - public Response serviceGetStat(@PathParam("statType") final String statType) { - statMessagesReceived++; - return Response.status(200).entity("{\"TYPE\": " + statType + "}").build(); - } - - /** - * Post to service instantiation. - * - * @param jsonString string to send - * @return http response - */ - @POST - @Path("/serviceInstantiation/v7") - public Response servicePostRequest(final String jsonString) { - postMessagesReceived++; - return buildResponse(jsonString); - } - - /** - * Post. - * - * @param serviceInstanceId service instance id - * @param vnfInstanceId vnf instance id - * @param jsonString json body - * @return http response - */ - @POST - @Path("/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") - public Response servicePostRequestVfModules(@PathParam("serviceInstanceId") final String serviceInstanceId, - @PathParam("vnfInstanceId") final String vnfInstanceId, final String jsonString) { - postMessagesReceived++; - return buildResponse(jsonString); - } - - /** - * Get instance ID. - * - * @param nsInstanceId node instance id - * @return http response - */ - @GET - @Path("/orchestrationRequests/v5/{nsInstanceId}") - public Response soRequestStatus(@PathParam("nsInstanceId") final String nsInstanceId) { - - SOResponse response = ongoingRequestMap.get(nsInstanceId); - - int iterationsLeft = Integer.valueOf(response.getRequest().getRequestScope()); - if (--iterationsLeft > 0) { - response.getRequest().setRequestScope(new Integer(iterationsLeft).toString()); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()).entity(responseString).build(); - } - - ongoingRequestMap.remove(nsInstanceId); - - if ("ReturnBadAfterWait".equals(response.getRequest().getRequestType())) { - return Response.status(400).build(); - } - - response.getRequest().getRequestStatus().setRequestState("COMPLETE"); - response.getRequest().setRequestScope("0"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()).entity(responseString).build(); - } - - /** - * Delete. - * - * @param serviceInstanceId service instance id - * @param vnfInstanceId vnf instance id - * @param vfModuleInstanceId vf module instance id - * @param jsonString json body - * @return http response - */ - @DELETE - @Path("/serviceInstances/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleInstanceId}") - public Response serviceDeleteRequestVfModules( - @PathParam("serviceInstanceId") final String serviceInstanceId, - @PathParam("vnfInstanceId") final String vnfInstanceId, - @PathParam("vfModuleInstanceId") final String vfModuleInstanceId, - final String jsonString) { - deleteMessagesReceived++; - return buildResponse(jsonString); - } - - private Response buildResponse(String jsonString) { - if (jsonString == null) { - return Response.status(400).build(); - } - - SORequest request = null; - try { - request = new Gson().fromJson(jsonString, SORequest.class); - } catch (Exception e) { - return Response.status(400).build(); - } - - if (request == null) { - return Response.status(400).build(); - } - - if (request.getRequestType() == null) { - return Response.status(400).build(); - } - - if ("ReturnBadJson".equals(request.getRequestType())) { - return Response.status(200) - .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\":" + " , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived - + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); - } - - SOResponse response = new SOResponse(); - response.setRequest(request); - response.setRequestReferences(new SORequestReferences()); - response.getRequestReferences().setRequestId(request.getRequestId().toString()); - - if ("ReturnCompleted".equals(request.getRequestType())) { - response.getRequest().getRequestStatus().setRequestState("COMPLETE"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnFailed".equals(request.getRequestType())) { - response.getRequest().getRequestStatus().setRequestState("FAILED"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnOnging202".equals(request.getRequestType())) { - ongoingRequestMap.put(request.getRequestId().toString(), response); - - response.getRequest().getRequestStatus().setRequestState("ONGOING"); - response.setHttpResponseCode(202); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnOnging200".equals(request.getRequestType())) { - ongoingRequestMap.put(request.getRequestId().toString(), response); - - response.getRequest().getRequestStatus().setRequestState("ONGOING"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnBadAfterWait".equals(request.getRequestType())) { - ongoingRequestMap.put(request.getRequestId().toString(), response); - - response.getRequest().getRequestStatus().setRequestState("ONGOING"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - return null; - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java deleted file mode 100755 index ee083ae08..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoInstanceReferences { - - @Test - public void testConstructor() { - SOInstanceReferences obj = new SOInstanceReferences(); - - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getRequestId() == null); - } - - @Test - public void testSetGet() { - SOInstanceReferences obj = new SOInstanceReferences(); - - obj.setInstanceId("instanceId"); - assertEquals("instanceId", obj.getInstanceId()); - - obj.setRequestId("requestId"); - assertEquals("requestId", obj.getRequestId()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoManager.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoManager.java deleted file mode 100644 index 20cb54fca..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoManager.java +++ /dev/null @@ -1,404 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * TestSOManager - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.net.URI; -import java.util.UUID; -import java.util.concurrent.Future; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.drools.core.WorkingMemory; -import org.glassfish.grizzly.http.server.HttpServer; -import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; -import org.glassfish.jersey.server.ResourceConfig; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.drools.system.PolicyEngine; - -public class TestSoManager { - private static final String BASE_URI = "http://localhost:46553/TestSOManager"; - private static final String BASE_SO_URI = BASE_URI + "/SO"; - private static HttpServer server; - - /** - * Set up test class. - */ - @BeforeClass - public static void setUp() throws IOException { - final ResourceConfig rc = new ResourceConfig(TestSoDummyServer.class); - //Grizzly by default doesn't allow payload for HTTP methods (ex: DELETE), for which HTTP spec doesn't - // explicitly state that. - //allow it before starting the server - server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc, false); - server.getServerConfiguration().setAllowPayloadForUndefinedHttpMethods(true); - server.start(); - } - - @AfterClass - public static void tearDown() throws Exception { - server.shutdown(); - } - - @Test - public void testGrizzlyServer() throws ClientProtocolException, IOException { - CloseableHttpClient httpclient = HttpClients.createDefault(); - HttpGet httpGet = new HttpGet("http://localhost:46553/TestSOManager/SO/Stats"); - CloseableHttpResponse response = httpclient.execute(httpGet); - - String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8"); - assertTrue(returnBody.matches("^\\{\"GET\": [0-9]*,\"STAT\": [0-9]*,\"POST\": [0-9]*,\"PUT\": [0-9]*," - + "\"DELETE\": [0-9]*\\}$")); - } - - @Test - public void testServiceInstantiation() throws IOException { - SOManager manager = new SOManager(); - assertNotNull(manager); - manager.setRestGetTimeout(100); - - SOResponse response = manager.createModuleInstance("http:/localhost:99999999", BASE_SO_URI, "sean", - "citizen", null); - assertNull(response); - - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", null); - assertNull(response); - - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", new SORequest()); - assertNull(response); - - SORequest request = new SORequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestScope("Test"); - request.setRequestType("ReturnBadJson"); - request.setStartTime("2018-03-23 16:31"); - request.setRequestStatus(new SORequestStatus()); - request.getRequestStatus().setRequestState("ONGOING"); - - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNull(response); - - request.setRequestType("ReturnCompleted"); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - - request.setRequestType("ReturnFailed"); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); - - // Use scope to set the number of iterations we'll wait for - - request.setRequestType("ReturnOnging200"); - request.setRequestScope(new Integer(10).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(20).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - - // Test timeout after 20 attempts for a response - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(21).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNull(response); - - // Test bad response after 3 attempts for a response - request.setRequestType("ReturnBadAfterWait"); - request.setRequestScope(new Integer(3).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNull(response); - } - - @Test - public void testVfModuleCreation() throws IOException { - SOManager manager = new SOManager(); - assertNotNull(manager); - manager.setRestGetTimeout(100); - - PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); - PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); - - WorkingMemory wm = new DummyWorkingMemory(); - - SORequest soRequest = new SORequest(); - soRequest.setOperationType(SoOperationType.SCALE_OUT); - PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); - Future asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, - UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), soRequest); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - SORequest request = new SORequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestScope("Test"); - request.setRequestType("ReturnBadJson"); - request.setStartTime("2018-03-23 16:31"); - request.setRequestStatus(new SORequestStatus()); - request.getRequestStatus().setRequestState("ONGOING"); - request.setOperationType(SoOperationType.SCALE_OUT); - - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnCompleted"); - - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnFailed"); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Use scope to set the number of iterations we'll wait for - - request.setRequestType("ReturnOnging200"); - request.setRequestScope(new Integer(10).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(20).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test timeout after 20 attempts for a response - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(21).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test bad response after 3 attempts for a response - request.setRequestType("ReturnBadAfterWait"); - request.setRequestScope(new Integer(3).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - } - - @Test - public void testVfModuleDeletion() { - SOManager manager = new SOManager(); - assertNotNull(manager); - manager.setRestGetTimeout(100); - - PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); - PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); - - WorkingMemory wm = new DummyWorkingMemory(); - - SORequest soRequest = new SORequest(); - soRequest.setOperationType(SoOperationType.DELETE_VF_MODULE); - PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); - Future asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, - UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - SORequest request = new SORequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestScope("Test"); - request.setRequestType("ReturnBadJson"); - request.setStartTime("2018-03-23 16:31"); - request.setRequestStatus(new SORequestStatus()); - request.getRequestStatus().setRequestState("ONGOING"); - request.setOperationType(SoOperationType.DELETE_VF_MODULE); - - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnCompleted"); - - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnFailed"); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Use scope to set the number of iterations we'll wait for - - request.setRequestType("ReturnOnging200"); - request.setRequestScope(new Integer(10).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(20).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test timeout after 20 attempts for a response - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(21).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test bad response after 3 attempts for a response - request.setRequestType("ReturnBadAfterWait"); - request.setRequestScope(new Integer(3).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java deleted file mode 100755 index 037e82e4c..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoModelInfo { - - @Test - public void testConstructor() { - SOModelInfo obj = new SOModelInfo(); - - assertTrue(obj.getModelCustomizationId() == null); - assertTrue(obj.getModelCustomizationName() == null); - assertTrue(obj.getModelInvariantId() == null); - assertTrue(obj.getModelName() == null); - assertTrue(obj.getModelType() == null); - assertTrue(obj.getModelVersion() == null); - assertTrue(obj.getModelVersionId() == null); - } - - @Test - public void testSetGet() { - SOModelInfo obj = new SOModelInfo(); - - obj.setModelCustomizationId("modelCustomizationId"); - assertEquals("modelCustomizationId", obj.getModelCustomizationId()); - - obj.setModelCustomizationName("modelCustomizationName"); - assertEquals("modelCustomizationName", obj.getModelCustomizationName()); - - obj.setModelInvariantId("modelInvariantId"); - assertEquals("modelInvariantId", obj.getModelInvariantId()); - - obj.setModelName("modelName"); - assertEquals("modelName", obj.getModelName()); - - obj.setModelType("modelType"); - assertEquals("modelType", obj.getModelType()); - - obj.setModelVersion("modelVersion"); - assertEquals("modelVersion", obj.getModelVersion()); - - obj.setModelVersionId("modelVersionId"); - assertEquals("modelVersionId", obj.getModelVersionId()); - - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyExceptionHolder.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyExceptionHolder.java deleted file mode 100755 index 1c619a8c6..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyExceptionHolder.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoPolicyExceptionHolder { - - @Test - public void testConstructor() { - SOPolicyExceptionHolder obj = new SOPolicyExceptionHolder(); - - assertTrue(obj.getMessageId() == null); - assertTrue(obj.getText() == null); - } - - @Test - public void testSetGet() { - SOPolicyExceptionHolder obj = new SOPolicyExceptionHolder(); - - obj.setMessageId("messageId"); - assertEquals("messageId", obj.getMessageId()); - - obj.setText("text"); - assertEquals("text", obj.getText()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java deleted file mode 100755 index 048288377..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRelatedInstance { - - @Test - public void testConstructor() { - SORelatedInstance obj = new SORelatedInstance(); - - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getInstanceName() == null); - assertTrue(obj.getModelInfo() == null); - } - - @Test - public void testSetGet() { - SORelatedInstance obj = new SORelatedInstance(); - - obj.setInstanceId("instanceId"); - assertEquals("instanceId", obj.getInstanceId()); - - obj.setInstanceName("instanceName"); - assertEquals("instanceName", obj.getInstanceName()); - - SOModelInfo modelInfo = new SOModelInfo(); - obj.setModelInfo(modelInfo); - assertEquals(modelInfo, obj.getModelInfo()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java deleted file mode 100755 index 83f1d5849..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRelatedInstanceListElement { - - @Test - public void testConstructor() { - SORelatedInstanceListElement obj = new SORelatedInstanceListElement(); - - assertTrue(obj.getRelatedInstance() == null); - } - - @Test - public void testSetGet() { - SORelatedInstanceListElement obj = new SORelatedInstanceListElement(); - - SORelatedInstance relatedInstance = new SORelatedInstance(); - obj.setRelatedInstance(relatedInstance); - assertEquals(relatedInstance, obj.getRelatedInstance()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java deleted file mode 100755 index 2f9bf68bb..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.LocalDateTime; -import java.util.UUID; - -import org.junit.Test; - -public class TestSoRequest { - - @Test - public void testConstructor() { - SORequest obj = new SORequest(); - - assertTrue(obj.getFinishTime() == null); - assertTrue(obj.getRequestDetails() == null); - assertTrue(obj.getRequestId() == null); - assertTrue(obj.getRequestScope() == null); - assertTrue(obj.getRequestStatus() == null); - assertTrue(obj.getRequestType() == null); - assertTrue(obj.getStartTime() == null); - } - - @Test - public void testSetGet() { - SORequest obj = new SORequest(); - - LocalDateTime finishTime = LocalDateTime.now(); - obj.setFinishTime(finishTime); - assertEquals(finishTime, obj.getFinishTime()); - - UUID uuid = UUID.randomUUID(); - obj.setRequestId(uuid); - assertEquals(uuid, obj.getRequestId()); - - obj.setRequestScope("requestScope"); - assertEquals("requestScope", obj.getRequestScope()); - - SORequestStatus requestStatus = new SORequestStatus(); - obj.setRequestStatus(requestStatus); - assertEquals(requestStatus, obj.getRequestStatus()); - - obj.setRequestType("requestType"); - assertEquals("requestType", obj.getRequestType()); - - obj.setOperationType(SoOperationType.DELETE_VF_MODULE); - assertEquals(SoOperationType.DELETE_VF_MODULE, obj.getOperationType()); - - LocalDateTime startTime = LocalDateTime.now(); - obj.setStartTime(startTime.toString()); - assertEquals(startTime.toString(), obj.getStartTime()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java deleted file mode 100755 index c4b024593..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class TestSoRequestDetails { - - @Test - public void testConstructor() { - SORequestDetails obj = new SORequestDetails(); - - assertTrue(obj.getCloudConfiguration() == null); - assertTrue(obj.getModelInfo() == null); - assertTrue(obj.getRequestInfo() == null); - assertTrue(obj.getRequestParameters() == null); - assertTrue(obj.getSubscriberInfo() == null); - - assertTrue(obj.getRelatedInstanceList() != null); - assertEquals(0, obj.getRelatedInstanceList().size()); - } - - @Test - public void testSetGet() { - SORequestDetails obj = new SORequestDetails(); - - SOCloudConfiguration cloudConfiguration = new SOCloudConfiguration(); - obj.setCloudConfiguration(cloudConfiguration); - assertEquals(cloudConfiguration, obj.getCloudConfiguration()); - - SOModelInfo modelInfo = new SOModelInfo(); - obj.setModelInfo(modelInfo); - assertEquals(modelInfo, obj.getModelInfo()); - - SORequestInfo requestInfo = new SORequestInfo(); - obj.setRequestInfo(requestInfo); - assertEquals(requestInfo, obj.getRequestInfo()); - - SORequestParameters requestParameters = new SORequestParameters(); - obj.setRequestParameters(requestParameters); - assertEquals(requestParameters, obj.getRequestParameters()); - - SOSubscriberInfo subscriberInfo = new SOSubscriberInfo(); - obj.setSubscriberInfo(subscriberInfo); - assertEquals(subscriberInfo, obj.getSubscriberInfo()); - } - - @Test - public void testSoMRequestDetailsMethods() { - SORequestDetails details = new SORequestDetails(); - assertNotNull(details); - assertNotEquals(0, details.hashCode()); - - SOCloudConfiguration cloudConfiguration = new SOCloudConfiguration(); - details.setCloudConfiguration(cloudConfiguration); - assertEquals(cloudConfiguration, details.getCloudConfiguration()); - assertNotEquals(0, details.hashCode()); - - SOModelInfo modelInfo = new SOModelInfo(); - details.setModelInfo(modelInfo); - assertEquals(modelInfo, details.getModelInfo()); - assertNotEquals(0, details.hashCode()); - - List relatedInstanceList = new ArrayList<>(); - details.setRelatedInstanceList(relatedInstanceList); - assertEquals(relatedInstanceList, details.getRelatedInstanceList()); - assertNotEquals(0, details.hashCode()); - - SORequestInfo requestInfo = new SORequestInfo(); - details.setRequestInfo(requestInfo); - assertEquals(requestInfo, details.getRequestInfo()); - assertNotEquals(0, details.hashCode()); - - SORequestParameters requestParameters = new SORequestParameters(); - details.setRequestParameters(requestParameters); - assertEquals(requestParameters, details.getRequestParameters()); - assertNotEquals(0, details.hashCode()); - - SOSubscriberInfo subscriberInfo = new SOSubscriberInfo(); - details.setSubscriberInfo(subscriberInfo); - assertEquals(subscriberInfo, details.getSubscriberInfo()); - assertNotEquals(0, details.hashCode()); - - assertEquals("SORequestDetails [modelInfo=org.onap.policy.so", details.toString().substring(0, 46)); - - SORequestDetails copiedDetails = new SORequestDetails(details); - - assertTrue(details.equals(details)); - assertTrue(details.equals(copiedDetails)); - assertFalse(details.equals(null)); - assertFalse(details.equals("Hello")); - - details.setCloudConfiguration(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setCloudConfiguration(null); - assertTrue(details.equals(copiedDetails)); - details.setCloudConfiguration(cloudConfiguration); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setCloudConfiguration(cloudConfiguration); - assertTrue(details.equals(copiedDetails)); - - details.setModelInfo(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setModelInfo(null); - assertTrue(details.equals(copiedDetails)); - details.setModelInfo(modelInfo); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setModelInfo(modelInfo); - assertTrue(details.equals(copiedDetails)); - - details.setRequestInfo(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestInfo(null); - assertTrue(details.equals(copiedDetails)); - details.setRequestInfo(requestInfo); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestInfo(requestInfo); - assertTrue(details.equals(copiedDetails)); - - details.setRequestParameters(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestParameters(null); - assertTrue(details.equals(copiedDetails)); - details.setRequestParameters(requestParameters); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestParameters(requestParameters); - assertTrue(details.equals(copiedDetails)); - - details.setSubscriberInfo(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setSubscriberInfo(null); - assertTrue(details.equals(copiedDetails)); - details.setSubscriberInfo(subscriberInfo); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setSubscriberInfo(subscriberInfo); - assertTrue(details.equals(copiedDetails)); - - details.setRelatedInstanceList(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRelatedInstanceList(null); - assertTrue(details.equals(copiedDetails)); - details.setRelatedInstanceList(relatedInstanceList); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRelatedInstanceList(relatedInstanceList); - assertTrue(details.equals(copiedDetails)); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java deleted file mode 100755 index a3c19cf41..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestError { - - @Test - public void testConstructor() { - SORequestError obj = new SORequestError(); - - assertTrue(obj.getPolicyException() == null); - assertTrue(obj.getServiceException() == null); - } - - @Test - public void testSetGet() { - SORequestError obj = new SORequestError(); - - SOPolicyExceptionHolder policyException = new SOPolicyExceptionHolder(); - obj.setPolicyException(policyException); - assertEquals(policyException, obj.getPolicyException()); - - SOServiceExceptionHolder serviceException = new SOServiceExceptionHolder(); - obj.setServiceException(serviceException); - assertEquals(serviceException, obj.getServiceException()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java deleted file mode 100755 index a77fe8bf4..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestInfo { - - @Test - public void testConstructor() { - SORequestInfo obj = new SORequestInfo(); - - assertTrue(obj.getBillingAccountNumber() == null); - assertTrue(obj.getCallbackUrl() == null); - assertTrue(obj.getCorrelator() == null); - assertTrue(obj.getInstanceName() == null); - assertTrue(obj.getOrderNumber() == null); - assertTrue(obj.getOrderVersion() == null); - assertTrue(obj.getProductFamilyId() == null); - assertTrue(obj.getRequestorId() == null); - assertTrue(obj.getSource() == null); - assertTrue(obj.isSuppressRollback() == false); - } - - @Test - public void testSetGet() { - SORequestInfo obj = new SORequestInfo(); - - obj.setBillingAccountNumber("billingAccountNumber"); - assertEquals("billingAccountNumber", obj.getBillingAccountNumber()); - - obj.setCallbackUrl("callbackUrl"); - assertEquals("callbackUrl", obj.getCallbackUrl()); - - obj.setCorrelator("correlator"); - assertEquals("correlator", obj.getCorrelator()); - - obj.setInstanceName("instanceName"); - assertEquals("instanceName", obj.getInstanceName()); - - obj.setOrderNumber("orderNumber"); - assertEquals("orderNumber", obj.getOrderNumber()); - - int orderVersion = 2008; - obj.setOrderVersion(orderVersion); - assertEquals((Integer) orderVersion, obj.getOrderVersion()); - - obj.setProductFamilyId("productFamilyId"); - assertEquals("productFamilyId", obj.getProductFamilyId()); - - obj.setRequestorId("requestorId"); - assertEquals("requestorId", obj.getRequestorId()); - - obj.setSource("source"); - assertEquals("source", obj.getSource()); - - obj.setSuppressRollback(true); - assertEquals(true, obj.isSuppressRollback()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java deleted file mode 100755 index 1ebf5d76f..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestParameters { - - @Test - public void testConstructor() { - SORequestParameters obj = new SORequestParameters(); - - assertTrue(obj.getSubscriptionServiceType() == null); - assertTrue(obj.getUserParams() != null); - assertEquals(0, obj.getUserParams().size()); - } - - @Test - public void testSetGet() { - SORequestParameters obj = new SORequestParameters(); - - obj.setSubscriptionServiceType("subscriptionServiceType"); - assertEquals("subscriptionServiceType", obj.getSubscriptionServiceType()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java deleted file mode 100755 index 498a2e00b..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestReferences { - - @Test - public void testConstructor() { - SORequestReferences obj = new SORequestReferences(); - - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getRequestId() == null); - } - - @Test - public void testSetGet() { - SORequestReferences obj = new SORequestReferences(); - - obj.setInstanceId("instanceId"); - assertEquals("instanceId", obj.getInstanceId()); - - obj.setRequestId("requestId"); - assertEquals("requestId", obj.getRequestId()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java deleted file mode 100755 index 1b8d745fd..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestStatus { - - @Test - public void testConstructor() { - SORequestStatus obj = new SORequestStatus(); - - assertEquals(0, obj.getPercentProgress()); - assertTrue(obj.getRequestState() == null); - assertTrue(obj.getTimestamp() == null); - assertFalse(obj.isWasRolledBack()); - } - - @Test - public void testSetGet() { - SORequestStatus obj = new SORequestStatus(); - - obj.setPercentProgress(2008); - assertEquals(2008, obj.getPercentProgress()); - - obj.setRequestState("requestState"); - assertEquals("requestState", obj.getRequestState()); - - obj.setTimestamp("timestamp"); - assertEquals("timestamp", obj.getTimestamp()); - - obj.setWasRolledBack(true); - assertTrue(obj.isWasRolledBack()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java deleted file mode 100755 index cf9a85e83..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoResponse { - - @Test - public void testConstructor() { - SOResponse obj = new SOResponse(); - - assertEquals(0, obj.getHttpResponseCode()); - assertTrue(obj.getRequest() == null); - assertTrue(obj.getRequestError() == null); - assertTrue(obj.getRequestReferences() == null); - } - - @Test - public void testSetGet() { - SOResponse obj = new SOResponse(); - - obj.setHttpResponseCode(2008); - assertEquals(2008, obj.getHttpResponseCode()); - - SORequest request = new SORequest(); - obj.setRequest(request); - assertEquals(request, obj.getRequest()); - - SORequestError requestError = new SORequestError(); - obj.setRequestError(requestError); - assertEquals(requestError, obj.getRequestError()); - - SORequestReferences requestReferences = new SORequestReferences(); - obj.setRequestReferences(requestReferences); - assertEquals(requestReferences, obj.getRequestReferences()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java deleted file mode 100755 index d7ef9708d..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.Test; - -public class TestSoResponseWrapper { - - @Test - public void testConstructor() { - SOResponse response = new SOResponse(); - SOResponseWrapper obj = new SOResponseWrapper(response, "reqID"); - - assertEquals(response, obj.getSoResponse()); - assertEquals("reqID", obj.getRequestID()); - } - - @Test - public void testSetGet() { - SOResponse response = new SOResponse(); - SOResponseWrapper obj = new SOResponseWrapper(response, "reqID"); - - SOResponse response2 = new SOResponse(); - response2.setHttpResponseCode(2008); - obj.setSoResponse(response2); - assertEquals(response2, obj.getSoResponse()); - - obj.setRequestID("id2"); - assertEquals("id2", obj.getRequestID()); - } - - @Test - public void testSoResponseWrapperMethods() { - String requestId = UUID.randomUUID().toString(); - SOResponse response = new SOResponse(); - - SOResponseWrapper responseWrapper = new SOResponseWrapper(response, requestId); - assertNotNull(responseWrapper); - assertNotEquals(0, responseWrapper.hashCode()); - - assertEquals(response, responseWrapper.getSoResponse()); - - assertNotEquals(0, responseWrapper.hashCode()); - - assertEquals("SOResponseWrapper [SOResponse=org.onap.policy.", responseWrapper.toString().substring(0, 46)); - - SOResponseWrapper identicalResponseWrapper = new SOResponseWrapper(response, requestId); - - assertEquals(responseWrapper, responseWrapper); - assertEquals(responseWrapper, identicalResponseWrapper); - assertNotEquals(null, responseWrapper); - assertNotEquals("Hello", responseWrapper); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("AString")); - - assertEquals(new SOResponseWrapper(null, null), new SOResponseWrapper(null, null)); - assertNotEquals(new SOResponseWrapper(null, null), identicalResponseWrapper); - - assertNotEquals(0, new SOResponseWrapper(null, null).hashCode()); - - identicalResponseWrapper.setSoResponse(new SOResponse()); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setSoResponse(response); - assertEquals(responseWrapper, identicalResponseWrapper); - - identicalResponseWrapper.setRequestID(UUID.randomUUID().toString()); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setRequestID(requestId); - assertEquals(responseWrapper, identicalResponseWrapper); - - responseWrapper.setRequestID(null); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setRequestID(null); - assertEquals(responseWrapper, identicalResponseWrapper); - responseWrapper.setRequestID(requestId); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setRequestID(requestId); - assertEquals(responseWrapper, identicalResponseWrapper); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceExceptionHolder.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceExceptionHolder.java deleted file mode 100755 index 7c802efaf..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceExceptionHolder.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoServiceExceptionHolder { - - @Test - public void testConstructor() { - SOServiceExceptionHolder obj = new SOServiceExceptionHolder(); - - assertTrue(obj.getMessageId() == null); - assertTrue(obj.getText() == null); - assertTrue(obj.getVariables() != null); - assertEquals(0, obj.getVariables().size()); - } - - @Test - public void testSetGet() { - SOServiceExceptionHolder obj = new SOServiceExceptionHolder(); - - obj.setMessageId("messageId"); - assertEquals("messageId", obj.getMessageId()); - - obj.setText("text"); - assertEquals("text", obj.getText()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java deleted file mode 100755 index b0662fa30..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoSubscriberInfo { - - @Test - public void testConstructor() { - SOSubscriberInfo obj = new SOSubscriberInfo(); - - assertTrue(obj.getGlobalSubscriberId() == null); - assertTrue(obj.getSubscriberCommonSiteId() == null); - assertTrue(obj.getSubscriberName() == null); - } - - @Test - public void testSetGet() { - SOSubscriberInfo obj = new SOSubscriberInfo(); - - obj.setGlobalSubscriberId("globalSubscriberId"); - assertEquals("globalSubscriberId", obj.getGlobalSubscriberId()); - - obj.setSubscriberCommonSiteId("subscriberCommonSiteId"); - assertEquals("subscriberCommonSiteId", obj.getSubscriberCommonSiteId()); - - obj.setSubscriberName("subscriberName"); - assertEquals("subscriberName", obj.getSubscriberName()); - } -} diff --git a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/DemoTest.java b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/DemoTest.java new file mode 100644 index 000000000..bd59f8bc1 --- /dev/null +++ b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/DemoTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * trafficgenerator + * ================================================================================ + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vnf.trafficgenerator; + +import org.junit.Test; + +import org.onap.policy.vnf.trafficgenerator.PGRequest; +import org.onap.policy.vnf.trafficgenerator.PGStream; +import org.onap.policy.vnf.trafficgenerator.PGStreams; +import org.onap.policy.vnf.trafficgenerator.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DemoTest { + private static final Logger logger = LoggerFactory.getLogger(DemoTest.class); + + @Test + public void test() { + PGRequest request = new PGRequest(); + request.pgStreams = new PGStreams(); + + PGStream pgStream; + for (int i = 0; i < 5; i++) { + pgStream = new PGStream(); + pgStream.streamId = "fw_udp" + (i + 1); + pgStream.isEnabled = "true"; + request.pgStreams.pgStream.add(pgStream); + } + + String body = Serialization.gsonPretty.toJson(request); + logger.debug(body); + + // fail("Not yet implemented"); + } + +} diff --git a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java b/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java deleted file mode 100644 index f35087794..000000000 --- a/controlloop/common/model-impl/trafficgenerator/src/test/java/org/onap/policy/vnf/trafficgenerator/TestDemo.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * trafficgenerator - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vnf.trafficgenerator; - -import org.junit.Test; - -import org.onap.policy.vnf.trafficgenerator.PGRequest; -import org.onap.policy.vnf.trafficgenerator.PGStream; -import org.onap.policy.vnf.trafficgenerator.PGStreams; -import org.onap.policy.vnf.trafficgenerator.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestDemo { - private static final Logger logger = LoggerFactory.getLogger(TestDemo.class); - - @Test - public void test() { - PGRequest request = new PGRequest(); - request.pgStreams = new PGStreams(); - - PGStream pgStream; - for (int i = 0; i < 5; i++) { - pgStream = new PGStream(); - pgStream.streamId = "fw_udp" + (i + 1); - pgStream.isEnabled = "true"; - request.pgStreams.pgStream.add(pgStream); - } - - String body = Serialization.gsonPretty.toJson(request); - logger.debug(body); - - // fail("Not yet implemented"); - } - -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java new file mode 100644 index 000000000..dae87b6a6 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/DemoTest.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2017 Intel Corp. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vfc; + +import java.util.LinkedList; + +import org.junit.Test; +import org.onap.policy.vfc.util.Serialization; + +public class DemoTest { + + @Test + public void test() { + VFCRequest request = new VFCRequest(); + + request.setNSInstanceId("100"); + request.setHealRequest(new VFCHealRequest()); + request.getHealRequest().setVnfInstanceId("1"); + request.getHealRequest().setCause("vm is down"); + + request.getHealRequest().setAdditionalParams(new VFCHealAdditionalParams()); + request.getHealRequest().getAdditionalParams().setAction("restartvm"); + + request.getHealRequest().getAdditionalParams().setActionInfo(new VFCHealActionVmInfo()); + request.getHealRequest().getAdditionalParams().getActionInfo().setVmid("33"); + request.getHealRequest().getAdditionalParams().getActionInfo().setVmname("xgw-smp11"); + + String body = Serialization.gsonPretty.toJson(request); + System.out.println(body); + + VFCResponse response = new VFCResponse(); + response.setJobId("1"); + + body = Serialization.gsonPretty.toJson(response); + System.out.println(body); + + response.setResponseDescriptor(new VFCResponseDescriptor()); + response.getResponseDescriptor().setProgress("40"); + response.getResponseDescriptor().setStatus("processing"); + response.getResponseDescriptor().setStatusDescription("OMC VMs are decommissioned in VIM"); + response.getResponseDescriptor().setErrorCode(null); + response.getResponseDescriptor().setResponseId("42"); + body = Serialization.gsonPretty.toJson(response); + System.out.println(body); + + VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + responseDescriptor.setProgress("20"); + responseDescriptor.setStatus("processing"); + responseDescriptor.setStatusDescription("OMC VMs are decommissioned in VIM"); + responseDescriptor.setErrorCode(null); + responseDescriptor.setResponseId("11"); + + response.getResponseDescriptor().setResponseHistoryList(new LinkedList<>()); + response.getResponseDescriptor().getResponseHistoryList().add(responseDescriptor); + + body = Serialization.gsonPretty.toJson(response); + System.out.println(body); + + response = Serialization.gsonPretty.fromJson(body, VFCResponse.class); + body = Serialization.gsonPretty.toJson(response); + System.out.println(body); + + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java deleted file mode 100644 index a5f40f30e..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestDemo.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2017 Intel Corp. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vfc; - -import java.util.LinkedList; - -import org.junit.Test; -import org.onap.policy.vfc.util.Serialization; - -public class TestDemo { - - @Test - public void test() { - VFCRequest request = new VFCRequest(); - - request.setNSInstanceId("100"); - request.setHealRequest(new VFCHealRequest()); - request.getHealRequest().setVnfInstanceId("1"); - request.getHealRequest().setCause("vm is down"); - - request.getHealRequest().setAdditionalParams(new VFCHealAdditionalParams()); - request.getHealRequest().getAdditionalParams().setAction("restartvm"); - - request.getHealRequest().getAdditionalParams().setActionInfo(new VFCHealActionVmInfo()); - request.getHealRequest().getAdditionalParams().getActionInfo().setVmid("33"); - request.getHealRequest().getAdditionalParams().getActionInfo().setVmname("xgw-smp11"); - - String body = Serialization.gsonPretty.toJson(request); - System.out.println(body); - - VFCResponse response = new VFCResponse(); - response.setJobId("1"); - - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - response.setResponseDescriptor(new VFCResponseDescriptor()); - response.getResponseDescriptor().setProgress("40"); - response.getResponseDescriptor().setStatus("processing"); - response.getResponseDescriptor().setStatusDescription("OMC VMs are decommissioned in VIM"); - response.getResponseDescriptor().setErrorCode(null); - response.getResponseDescriptor().setResponseId("42"); - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); - responseDescriptor.setProgress("20"); - responseDescriptor.setStatus("processing"); - responseDescriptor.setStatusDescription("OMC VMs are decommissioned in VIM"); - responseDescriptor.setErrorCode(null); - responseDescriptor.setResponseId("11"); - - response.getResponseDescriptor().setResponseHistoryList(new LinkedList<>()); - response.getResponseDescriptor().getResponseHistoryList().add(responseDescriptor); - - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - response = Serialization.gsonPretty.fromJson(body, VFCResponse.class); - body = Serialization.gsonPretty.toJson(response); - System.out.println(body); - - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealActionVmInfo.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealActionVmInfo.java deleted file mode 100644 index 55f9ab8d5..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealActionVmInfo.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class TestVfcHealActionVmInfo { - - @Test - public void testVfcHealActionVmInfo() { - VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); - assertNotNull(actionInfo); - assertNotEquals(0, actionInfo.hashCode()); - - String vmid = "ECity"; - actionInfo.setVmid(vmid); - assertEquals(vmid, actionInfo.getVmid()); - - String vmName = "Emerald City"; - actionInfo.setVmname(vmName); - assertEquals(vmName, actionInfo.getVmname()); - - assertNotEquals(0, actionInfo.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealAdditionalParams.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealAdditionalParams.java deleted file mode 100644 index b74fe1a93..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealAdditionalParams.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class TestVfcHealAdditionalParams { - - @Test - public void testVfcHealAdditionalParameters() { - VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); - assertNotNull(additionalParams); - assertNotEquals(0, additionalParams.hashCode()); - - String action = "Go Home"; - additionalParams.setAction(action); - assertEquals(action, additionalParams.getAction()); - - VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); - additionalParams.setActionInfo(actionInfo ); - assertEquals(actionInfo, additionalParams.getActionInfo()); - - assertNotEquals(0, additionalParams.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealRequest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealRequest.java deleted file mode 100644 index 4c442bc2c..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcHealRequest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class TestVfcHealRequest { - - @Test - public void testVfcHealRequest() { - VFCHealRequest request = new VFCHealRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - String vnfInstanceId = "Go To Oz"; - request.setVnfInstanceId(vnfInstanceId); - assertEquals(vnfInstanceId, request.getVnfInstanceId()); - - String cause = "West Witch"; - request.setCause(cause); - assertEquals(cause, request.getCause()); - - VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); - request.setAdditionalParams(additionalParams); - assertEquals(additionalParams, request.getAdditionalParams()); - - assertNotEquals(0, request.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcManager.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcManager.java deleted file mode 100644 index 7e4bda81d..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcManager.java +++ /dev/null @@ -1,293 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson, AT&T. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.endsWith; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.ArgumentMatchers.startsWith; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.drools.core.WorkingMemory; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.drools.system.PolicyEngine; -import org.onap.policy.rest.RESTManager; -import org.onap.policy.rest.RESTManager.Pair; -import org.onap.policy.vfc.util.Serialization; - -public class TestVfcManager { - private static WorkingMemory mockedWorkingMemory; - - private RESTManager mockedRestManager; - - private Pair httpResponsePutOk; - private Pair httpResponseGetOk; - private Pair httpResponseBadResponse; - private Pair httpResponseErr; - - private VFCRequest request; - private VFCResponse response; - - @BeforeClass - public static void beforeTestVfcManager() { - mockedWorkingMemory = mock(WorkingMemory.class); - } - - /** - * Set up the mocked REST manager. - */ - @Before - public void setupMockedRest() { - mockedRestManager = mock(RESTManager.class); - - httpResponsePutOk = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(response)); - httpResponseGetOk = mockedRestManager.new Pair<>(200, Serialization.gsonPretty.toJson(response)); - httpResponseBadResponse = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(null)); - httpResponseErr = mockedRestManager.new Pair<>(200, null); - } - - /** - * Create the request and response before. - */ - @Before - public void createRequestAndResponse() { - VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); - actionInfo.setVmid("TheWizard"); - actionInfo.setVmname("The Wizard of Oz"); - - VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); - additionalParams.setAction("Go Home"); - additionalParams.setActionInfo(actionInfo); - - VFCHealRequest healRequest = new VFCHealRequest(); - healRequest.setAdditionalParams(additionalParams); - healRequest.setCause("WestWitch"); - healRequest.setVnfInstanceId("EmeraldCity"); - - final UUID requestId = UUID.randomUUID(); - request = new VFCRequest(); - request.setHealRequest(healRequest); - request.setNSInstanceId("Dorothy"); - request.setRequestId(requestId); - - List responseHistoryList = new ArrayList<>();; - - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); - responseDescriptor.setErrorCode("1234"); - responseDescriptor.setProgress("Follow The Yellow Brick Road"); - responseDescriptor.setResponseHistoryList(responseHistoryList); - responseDescriptor.setResponseId(UUID.randomUUID().toString()); - responseDescriptor.setStatus("finished"); - responseDescriptor.setStatusDescription("There's no place like home"); - - response = new VFCResponse(); - response.setJobId("1234"); - response.setRequestId(request.getRequestId().toString()); - response.setResponseDescriptor(responseDescriptor); - } - - /** - * Remove the environnment. - */ - @After - public void tearDown() { - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcInitiation() { - try { - new VFCManager(null, null); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals("the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null", - e.getMessage()); - } - - try { - new VFCManager(mockedWorkingMemory, null); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals("the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null", - e.getMessage()); - } - - try { - new VFCManager(mockedWorkingMemory, request); - fail("test should throw an exception here"); - } - catch (IllegalArgumentException e) { - assertEquals("The value of policy engine manager environment property \"vfc.url\" may not be null", - e.getMessage()); - } - - // add url; username & password are not required - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - new VFCManager(mockedWorkingMemory, request); - - // url & username, but no password - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - - // url, username, and password - PolicyEngine.manager.getEnvironment().put("vfc.password", "Toto"); - new VFCManager(mockedWorkingMemory, request); - } - - @Test - public void testVfcExecutionException() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "Exception"); - - VFCManager manager = new VFCManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post( - startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), - eq("Exception"), - anyMap(), - anyString(), - anyString())) - .thenThrow(new RuntimeException("OzException")); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcExecutionNull() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "Null"); - - VFCManager manager = new VFCManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), eq("Null"), anyMap(), anyString(), anyString())) - .thenReturn(null); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcExecutionError0() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "Error0"); - - VFCManager manager = new VFCManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), eq("Error0"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponseErr); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcExecutionBadResponse() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "BadResponse"); - - VFCManager manager = new VFCManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponseBadResponse); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } - - @Test - public void testVfcExecutionOk() throws InterruptedException { - PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); - PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); - PolicyEngine.manager.getEnvironment().put("vfc.password", "OK"); - - VFCManager manager = new VFCManager(mockedWorkingMemory, request); - manager.setRestManager(mockedRestManager); - - Thread managerThread = new Thread(manager); - managerThread.start(); - - when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), - eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) - .thenReturn(httpResponsePutOk); - - when(mockedRestManager.get(endsWith("1234"), eq("Dorothy"), eq("OK"), anyMap())) - .thenReturn(httpResponseGetOk); - - managerThread.join(); - - PolicyEngine.manager.getEnvironment().remove("vfc.password"); - PolicyEngine.manager.getEnvironment().remove("vfc.username"); - PolicyEngine.manager.getEnvironment().remove("vfc.url"); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcRequest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcRequest.java deleted file mode 100644 index 0ec5d7d82..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcRequest.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.Test; - -public class TestVfcRequest { - - @Test - public void testVfcRequest() { - VFCRequest request = new VFCRequest(); - assertNotNull(request); - assertNotEquals(0, request.hashCode()); - - String nsInstanceId = "Dorothy"; - request.setNSInstanceId(nsInstanceId); - assertEquals(nsInstanceId, request.getNSInstanceId()); - - UUID requestId = UUID.randomUUID(); - request.setRequestId(requestId); - assertEquals(requestId, request.getRequestId()); - - VFCHealRequest healRequest = new VFCHealRequest(); - request.setHealRequest(healRequest); - assertEquals(healRequest, request.getHealRequest()); - - assertNotEquals(0, request.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcResponse.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcResponse.java deleted file mode 100644 index 698459ad2..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcResponse.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class TestVfcResponse { - - @Test - public void testVfcResponse() { - VFCResponse response = new VFCResponse(); - assertNotNull(response); - assertNotEquals(0, response.hashCode()); - - String jobId = "GetToOz"; - response.setJobId(jobId); - assertEquals(jobId, response.getJobId()); - - String requestId = "Get Home"; - response.setRequestId(requestId); - assertEquals(requestId, response.getRequestId()); - - VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); - response.setResponseDescriptor(responseDescriptor); - assertEquals(responseDescriptor, response.getResponseDescriptor()); - - assertNotEquals(0, response.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcResponseDescriptor.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcResponseDescriptor.java deleted file mode 100644 index 927306fd8..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/TestVfcResponseDescriptor.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vfc; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class TestVfcResponseDescriptor { - - @Test - public void testVfcResponseDescriptor() { - VFCResponseDescriptor descriptor = new VFCResponseDescriptor(); - assertNotNull(descriptor); - assertNotEquals(0, descriptor.hashCode()); - - String errorCode = "WitchIsDead"; - descriptor.setErrorCode(errorCode); - assertEquals(errorCode, descriptor.getErrorCode()); - - String progress = "Visited Wizard"; - descriptor.setProgress(progress); - assertEquals(progress, descriptor.getProgress()); - - List responseHistoryList = new ArrayList<>(); - descriptor.setResponseHistoryList(responseHistoryList); - assertEquals(responseHistoryList, descriptor.getResponseHistoryList()); - - String responseId = "WishHard"; - descriptor.setResponseId(responseId); - assertEquals(responseId, descriptor.getResponseId()); - - String status = "Back in Kansas"; - descriptor.setStatus(status); - assertEquals(status, descriptor.getStatus()); - - String statusDescription = "Back on the prairie"; - descriptor.setStatusDescription(statusDescription); - assertEquals(statusDescription, descriptor.getStatusDescription()); - - assertNotEquals(0, descriptor.hashCode()); - } -} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java new file mode 100644 index 000000000..10964a909 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealActionVmInfoTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vfc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class VfcHealActionVmInfoTest { + + @Test + public void testVfcHealActionVmInfo() { + VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); + assertNotNull(actionInfo); + assertNotEquals(0, actionInfo.hashCode()); + + String vmid = "ECity"; + actionInfo.setVmid(vmid); + assertEquals(vmid, actionInfo.getVmid()); + + String vmName = "Emerald City"; + actionInfo.setVmname(vmName); + assertEquals(vmName, actionInfo.getVmname()); + + assertNotEquals(0, actionInfo.hashCode()); + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java new file mode 100644 index 000000000..ca2d844c1 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealAdditionalParamsTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vfc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class VfcHealAdditionalParamsTest { + + @Test + public void testVfcHealAdditionalParameters() { + VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); + assertNotNull(additionalParams); + assertNotEquals(0, additionalParams.hashCode()); + + String action = "Go Home"; + additionalParams.setAction(action); + assertEquals(action, additionalParams.getAction()); + + VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); + additionalParams.setActionInfo(actionInfo ); + assertEquals(actionInfo, additionalParams.getActionInfo()); + + assertNotEquals(0, additionalParams.hashCode()); + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java new file mode 100644 index 000000000..0a256a59b --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcHealRequestTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vfc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class VfcHealRequestTest { + + @Test + public void testVfcHealRequest() { + VFCHealRequest request = new VFCHealRequest(); + assertNotNull(request); + assertNotEquals(0, request.hashCode()); + + String vnfInstanceId = "Go To Oz"; + request.setVnfInstanceId(vnfInstanceId); + assertEquals(vnfInstanceId, request.getVnfInstanceId()); + + String cause = "West Witch"; + request.setCause(cause); + assertEquals(cause, request.getCause()); + + VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); + request.setAdditionalParams(additionalParams); + assertEquals(additionalParams, request.getAdditionalParams()); + + assertNotEquals(0, request.hashCode()); + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java new file mode 100644 index 000000000..ab8161164 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcManagerTest.java @@ -0,0 +1,293 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Ericsson, AT&T. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vfc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import static org.mockito.ArgumentMatchers.anyMap; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.endsWith; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.startsWith; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import org.drools.core.WorkingMemory; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.rest.RESTManager; +import org.onap.policy.rest.RESTManager.Pair; +import org.onap.policy.vfc.util.Serialization; + +public class VfcManagerTest { + private static WorkingMemory mockedWorkingMemory; + + private RESTManager mockedRestManager; + + private Pair httpResponsePutOk; + private Pair httpResponseGetOk; + private Pair httpResponseBadResponse; + private Pair httpResponseErr; + + private VFCRequest request; + private VFCResponse response; + + @BeforeClass + public static void beforeTestVfcManager() { + mockedWorkingMemory = mock(WorkingMemory.class); + } + + /** + * Set up the mocked REST manager. + */ + @Before + public void setupMockedRest() { + mockedRestManager = mock(RESTManager.class); + + httpResponsePutOk = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(response)); + httpResponseGetOk = mockedRestManager.new Pair<>(200, Serialization.gsonPretty.toJson(response)); + httpResponseBadResponse = mockedRestManager.new Pair<>(202, Serialization.gsonPretty.toJson(null)); + httpResponseErr = mockedRestManager.new Pair<>(200, null); + } + + /** + * Create the request and response before. + */ + @Before + public void createRequestAndResponse() { + VFCHealActionVmInfo actionInfo = new VFCHealActionVmInfo(); + actionInfo.setVmid("TheWizard"); + actionInfo.setVmname("The Wizard of Oz"); + + VFCHealAdditionalParams additionalParams = new VFCHealAdditionalParams(); + additionalParams.setAction("Go Home"); + additionalParams.setActionInfo(actionInfo); + + VFCHealRequest healRequest = new VFCHealRequest(); + healRequest.setAdditionalParams(additionalParams); + healRequest.setCause("WestWitch"); + healRequest.setVnfInstanceId("EmeraldCity"); + + final UUID requestId = UUID.randomUUID(); + request = new VFCRequest(); + request.setHealRequest(healRequest); + request.setNSInstanceId("Dorothy"); + request.setRequestId(requestId); + + List responseHistoryList = new ArrayList<>();; + + VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + responseDescriptor.setErrorCode("1234"); + responseDescriptor.setProgress("Follow The Yellow Brick Road"); + responseDescriptor.setResponseHistoryList(responseHistoryList); + responseDescriptor.setResponseId(UUID.randomUUID().toString()); + responseDescriptor.setStatus("finished"); + responseDescriptor.setStatusDescription("There's no place like home"); + + response = new VFCResponse(); + response.setJobId("1234"); + response.setRequestId(request.getRequestId().toString()); + response.setResponseDescriptor(responseDescriptor); + } + + /** + * Remove the environnment. + */ + @After + public void tearDown() { + PolicyEngine.manager.getEnvironment().remove("vfc.password"); + PolicyEngine.manager.getEnvironment().remove("vfc.username"); + PolicyEngine.manager.getEnvironment().remove("vfc.url"); + } + + @Test + public void testVfcInitiation() { + try { + new VFCManager(null, null); + fail("test should throw an exception here"); + } + catch (IllegalArgumentException e) { + assertEquals("the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null", + e.getMessage()); + } + + try { + new VFCManager(mockedWorkingMemory, null); + fail("test should throw an exception here"); + } + catch (IllegalArgumentException e) { + assertEquals("the parameters \"wm\" and \"request\" on the VFCManager constructor may not be null", + e.getMessage()); + } + + try { + new VFCManager(mockedWorkingMemory, request); + fail("test should throw an exception here"); + } + catch (IllegalArgumentException e) { + assertEquals("The value of policy engine manager environment property \"vfc.url\" may not be null", + e.getMessage()); + } + + // add url; username & password are not required + PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); + new VFCManager(mockedWorkingMemory, request); + + // url & username, but no password + PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); + + // url, username, and password + PolicyEngine.manager.getEnvironment().put("vfc.password", "Toto"); + new VFCManager(mockedWorkingMemory, request); + } + + @Test + public void testVfcExecutionException() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("vfc.password", "Exception"); + + VFCManager manager = new VFCManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post( + startsWith("http://somewhere.over.the.rainbow"), + eq("Dorothy"), + eq("Exception"), + anyMap(), + anyString(), + anyString())) + .thenThrow(new RuntimeException("OzException")); + + managerThread.join(); + + PolicyEngine.manager.getEnvironment().remove("vfc.password"); + PolicyEngine.manager.getEnvironment().remove("vfc.username"); + PolicyEngine.manager.getEnvironment().remove("vfc.url"); + } + + @Test + public void testVfcExecutionNull() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("vfc.password", "Null"); + + VFCManager manager = new VFCManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), + eq("Dorothy"), eq("Null"), anyMap(), anyString(), anyString())) + .thenReturn(null); + + managerThread.join(); + + PolicyEngine.manager.getEnvironment().remove("vfc.password"); + PolicyEngine.manager.getEnvironment().remove("vfc.username"); + PolicyEngine.manager.getEnvironment().remove("vfc.url"); + } + + @Test + public void testVfcExecutionError0() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("vfc.password", "Error0"); + + VFCManager manager = new VFCManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), + eq("Dorothy"), eq("Error0"), anyMap(), anyString(), anyString())) + .thenReturn(httpResponseErr); + + managerThread.join(); + + PolicyEngine.manager.getEnvironment().remove("vfc.password"); + PolicyEngine.manager.getEnvironment().remove("vfc.username"); + PolicyEngine.manager.getEnvironment().remove("vfc.url"); + } + + @Test + public void testVfcExecutionBadResponse() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("vfc.password", "BadResponse"); + + VFCManager manager = new VFCManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), + eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) + .thenReturn(httpResponseBadResponse); + + managerThread.join(); + + PolicyEngine.manager.getEnvironment().remove("vfc.password"); + PolicyEngine.manager.getEnvironment().remove("vfc.username"); + PolicyEngine.manager.getEnvironment().remove("vfc.url"); + } + + @Test + public void testVfcExecutionOk() throws InterruptedException { + PolicyEngine.manager.getEnvironment().put("vfc.url", "http://somewhere.over.the.rainbow"); + PolicyEngine.manager.getEnvironment().put("vfc.username", "Dorothy"); + PolicyEngine.manager.getEnvironment().put("vfc.password", "OK"); + + VFCManager manager = new VFCManager(mockedWorkingMemory, request); + manager.setRestManager(mockedRestManager); + + Thread managerThread = new Thread(manager); + managerThread.start(); + + when(mockedRestManager.post(startsWith("http://somewhere.over.the.rainbow"), + eq("Dorothy"), eq("OK"), anyMap(), anyString(), anyString())) + .thenReturn(httpResponsePutOk); + + when(mockedRestManager.get(endsWith("1234"), eq("Dorothy"), eq("OK"), anyMap())) + .thenReturn(httpResponseGetOk); + + managerThread.join(); + + PolicyEngine.manager.getEnvironment().remove("vfc.password"); + PolicyEngine.manager.getEnvironment().remove("vfc.username"); + PolicyEngine.manager.getEnvironment().remove("vfc.url"); + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java new file mode 100644 index 000000000..95589154f --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcRequestTest.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vfc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.UUID; + +import org.junit.Test; + +public class VfcRequestTest { + + @Test + public void testVfcRequest() { + VFCRequest request = new VFCRequest(); + assertNotNull(request); + assertNotEquals(0, request.hashCode()); + + String nsInstanceId = "Dorothy"; + request.setNSInstanceId(nsInstanceId); + assertEquals(nsInstanceId, request.getNSInstanceId()); + + UUID requestId = UUID.randomUUID(); + request.setRequestId(requestId); + assertEquals(requestId, request.getRequestId()); + + VFCHealRequest healRequest = new VFCHealRequest(); + request.setHealRequest(healRequest); + assertEquals(healRequest, request.getHealRequest()); + + assertNotEquals(0, request.hashCode()); + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java new file mode 100644 index 000000000..9ab180767 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseDescriptorTest.java @@ -0,0 +1,67 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vfc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class VfcResponseDescriptorTest { + + @Test + public void testVfcResponseDescriptor() { + VFCResponseDescriptor descriptor = new VFCResponseDescriptor(); + assertNotNull(descriptor); + assertNotEquals(0, descriptor.hashCode()); + + String errorCode = "WitchIsDead"; + descriptor.setErrorCode(errorCode); + assertEquals(errorCode, descriptor.getErrorCode()); + + String progress = "Visited Wizard"; + descriptor.setProgress(progress); + assertEquals(progress, descriptor.getProgress()); + + List responseHistoryList = new ArrayList<>(); + descriptor.setResponseHistoryList(responseHistoryList); + assertEquals(responseHistoryList, descriptor.getResponseHistoryList()); + + String responseId = "WishHard"; + descriptor.setResponseId(responseId); + assertEquals(responseId, descriptor.getResponseId()); + + String status = "Back in Kansas"; + descriptor.setStatus(status); + assertEquals(status, descriptor.getStatus()); + + String statusDescription = "Back on the prairie"; + descriptor.setStatusDescription(statusDescription); + assertEquals(statusDescription, descriptor.getStatusDescription()); + + assertNotEquals(0, descriptor.hashCode()); + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java new file mode 100644 index 000000000..f333c4165 --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/VfcResponseTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vfc; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class VfcResponseTest { + + @Test + public void testVfcResponse() { + VFCResponse response = new VFCResponse(); + assertNotNull(response); + assertNotEquals(0, response.hashCode()); + + String jobId = "GetToOz"; + response.setJobId(jobId); + assertEquals(jobId, response.getJobId()); + + String requestId = "Get Home"; + response.setRequestId(requestId); + assertEquals(requestId, response.getRequestId()); + + VFCResponseDescriptor responseDescriptor = new VFCResponseDescriptor(); + response.setResponseDescriptor(responseDescriptor); + assertEquals(responseDescriptor, response.getResponseDescriptor()); + + assertNotEquals(0, response.hashCode()); + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/SerializationTest.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/SerializationTest.java new file mode 100644 index 000000000..beceb045a --- /dev/null +++ b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/SerializationTest.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * vfc + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.vfc.util; + +import static org.junit.Assert.assertNotNull; + +import org.junit.Test; + +public class SerializationTest { + + @Test + public void test() { + assertNotNull(Serialization.gsonPretty); + } +} diff --git a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/TestSerialization.java b/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/TestSerialization.java deleted file mode 100644 index b66806213..000000000 --- a/controlloop/common/model-impl/vfc/src/test/java/org/onap/policy/vfc/util/TestSerialization.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * vfc - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 AT&T Corporation. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.vfc.util; - -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; - -public class TestSerialization { - - @Test - public void test() { - assertNotNull(Serialization.gsonPretty); - } -} -- cgit 1.2.3-korg