diff options
Diffstat (limited to 'UniversalVesAdapter/src/test/java/org/onap')
17 files changed, 756 insertions, 3 deletions
diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DmaapMrBaseConfigTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DmaapMrBaseConfigTest.java index 495722f..e0b72de 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DmaapMrBaseConfigTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DmaapMrBaseConfigTest.java @@ -1,6 +1,7 @@ /*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Samsung. All rights reserved.
+ * Copyright (C) 2022 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.
@@ -22,11 +23,18 @@ package org.onap.universalvesadapter.configs; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotEquals;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.universalvesadapter.exception.DMaapException;
+import org.onap.universalvesadapter.utils.DmaapConfig;
+
+import java.io.IOException;
+
public class DmaapMrBaseConfigTest {
DMaaPMRBaseConfig dmaapMrBaseConfig = null;
@@ -75,4 +83,105 @@ public class DmaapMrBaseConfigTest { assertEquals(JSON_APPLICATION_TYPE,
DMaaPMRBaseConfig.normalizeValidateContentType("application/json"));
}
+
+ @Test
+ public void testDMaaPMRSubscriberConfig() throws IOException {
+ DMaaPMRSubscriberConfig dMaaPMRSubscriberConfig = new DMaaPMRSubscriberConfig(new DMaaPMRSubscriberConfig
+ .Builder("test", new DmaapConfig()));
+ assertNotNull(dMaaPMRSubscriberConfig);
+ String timeout = dMaaPMRSubscriberConfig.getTimeoutMSParam();
+ assertNull(timeout);
+ dMaaPMRSubscriberConfig.setTimeoutMSParam("10");
+ timeout = dMaaPMRSubscriberConfig.getTimeoutMSParam();
+ assertNotNull(timeout);
+ String limitParam = dMaaPMRSubscriberConfig.getMessageLimitParam();
+ assertNull(limitParam);
+ dMaaPMRSubscriberConfig.setMessageLimitParam("test");
+ dMaaPMRSubscriberConfig.setUriPrefix("test");
+ String uriPrefix = dMaaPMRSubscriberConfig.getUriPrefix();
+ assertNotNull(uriPrefix);
+ String consumerId = dMaaPMRSubscriberConfig.getConsumerId();
+ assertNull(consumerId);
+ String consumerGroup = dMaaPMRSubscriberConfig.getConsumerGroup();
+ assertNull(consumerGroup);
+ int timeoutMS = dMaaPMRSubscriberConfig.getTimeoutMS();
+ assertEquals(0, timeoutMS);
+ int messageLimit = dMaaPMRSubscriberConfig.getMessageLimit();
+ assertEquals(0, messageLimit);
+ boolean result = dMaaPMRSubscriberConfig.equals(new Object());
+ assertFalse(result);
+ result = dMaaPMRSubscriberConfig.equals(new DMaaPMRSubscriberConfig(new DMaaPMRSubscriberConfig
+ .Builder("test", new DmaapConfig())));
+ assertTrue(result);
+ int res = dMaaPMRSubscriberConfig.hashCode();
+ assertNotEquals(0, res);
+ }
+
+ @Test
+ public void testDMaaPMRSubscriberConfigBuilder() throws IOException {
+ DMaaPMRSubscriberConfig.Builder builder = new DMaaPMRSubscriberConfig
+ .Builder("test", new DmaapConfig());
+ DMaaPMRSubscriberConfig.Builder builder1 = builder.setPortNumber(1234);
+ assertNotNull(builder1);
+ builder1 = builder.setUserName("john");
+ assertNotNull(builder1);
+ builder1 = builder.setUserPassword("sample");
+ assertNotNull(builder1);
+ builder1 = builder.setProtocol("HTTPS");
+ assertNotNull(builder1);
+ builder1 = builder.setContentType("application/json");
+ assertNotNull(builder1);
+ builder1 = builder.setConsumerId("1234");
+ assertNotNull(builder1);
+ builder1 = builder.setConsumerGroup("consumergroup");
+ assertNotNull(builder1);
+ builder1 = builder.setTimeoutMS(10);
+ assertNotNull(builder1);
+ builder1 = builder.setMessageLimit(10);
+ assertNotNull(builder1);
+ DMaaPMRSubscriberConfig dMaaPMRSubscriberConfig = builder.build();
+ assertNotNull(dMaaPMRSubscriberConfig);
+ }
+
+ @Test
+ public void testDMaaPMRPublisherConfig() throws IOException {
+ DMaaPMRPublisherConfig dMaaPMRPublisherConfig = new DMaaPMRPublisherConfig(new DMaaPMRPublisherConfig
+ .Builder("test", new DmaapConfig()));
+ assertNotNull(dMaaPMRPublisherConfig);
+ String uriPathPrefix = dMaaPMRPublisherConfig.getDmaapUriPathPrefix();
+ assertNull(uriPathPrefix);
+ int maxBatchSize = dMaaPMRPublisherConfig.getMaxBatchSize();
+ assertEquals(0, maxBatchSize);
+ int maxRecoveryQueueSize = dMaaPMRPublisherConfig.getMaxRecoveryQueueSize();
+ assertEquals(0, maxRecoveryQueueSize);
+ boolean result = dMaaPMRPublisherConfig.equals(new Object());
+ assertFalse(result);
+ result = dMaaPMRPublisherConfig.equals(new DMaaPMRPublisherConfig(new DMaaPMRPublisherConfig
+ .Builder("test", new DmaapConfig())));
+ assertTrue(result);
+ int res = dMaaPMRPublisherConfig.hashCode();
+ assertNotEquals(0, res);
+ }
+
+ @Test
+ public void testDMaaPMRPublisherConfigBuilder() throws IOException {
+ DMaaPMRPublisherConfig.Builder builder = new DMaaPMRPublisherConfig
+ .Builder("test", new DmaapConfig());
+ DMaaPMRPublisherConfig.Builder builder1 = builder.setPortNumber(1234);
+ assertNotNull(builder1);
+ builder1 = builder.setUserName("john");
+ assertNotNull(builder1);
+ builder1 = builder.setUserPassword("sample");
+ assertNotNull(builder1);
+ builder1 = builder.setProtocol("HTTPS");
+ assertNotNull(builder1);
+ builder1 = builder.setContentType("application/json");
+ assertNotNull(builder1);
+ builder1 = builder.setMaxBatchSize(10);
+ assertNotNull(builder1);
+ builder1 = builder.setMaxRecoveryQueueSize(10);
+ assertNotNull(builder1);
+ DMaaPMRPublisherConfig dMaaPMRPublisherConfig = builder.build();
+ assertNotNull(dMaaPMRPublisherConfig);
+ }
}
diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/CreatorTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/CreatorTest.java new file mode 100755 index 0000000..0d5a486 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/CreatorTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.dmaap; + +import org.junit.Test; +import org.onap.universalvesadapter.dmaap.MRSubcriber.DMaaPMRSubscriber; +import org.onap.universalvesadapter.utils.DmaapConfig; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +public class CreatorTest { + @Test + public void testGetDmaapConfig() { + Creator creator = new Creator(); + creator.setDmaapConfig(new DmaapConfig()); + DmaapConfig dmaapConfig = creator.getDmaapConfig(); + assertNotNull(dmaapConfig); + } + + @Test + public void testGetDMaaPMRPublisher() { + Creator creator = new Creator(); + creator.setDmaapConfig(new DmaapConfig()); + try { + creator.getDMaaPMRPublisher("test"); + } catch (IllegalArgumentException e) { + // expected case + return; + } + + fail("Exception is not thrown"); + } + + @Test + public void testGetDMaaPMRSubscriber() { + Creator creator = new Creator(); + creator.setDmaapConfig(new DmaapConfig()); + DMaaPMRSubscriber dMaaPMRSubscriber = creator.getDMaaPMRSubscriber("test"); + assertNotNull(dMaaPMRSubscriber); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/MRPublisher/DMaaPMRPublisherQueueImplTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/MRPublisher/DMaaPMRPublisherQueueImplTest.java new file mode 100755 index 0000000..ac5007a --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/MRPublisher/DMaaPMRPublisherQueueImplTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.dmaap.MRPublisher; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class DMaaPMRPublisherQueueImplTest { + @Test + public void testDMaaPMRPublisherQueueImpl() { + DMaaPMRPublisherQueueImpl dMaaPMRPublisherQueue = new DMaaPMRPublisherQueueImpl(2, 2); + List<String> messages = new ArrayList<>(); + messages.add("msg"); + int result = dMaaPMRPublisherQueue.addBatchMessages(messages); + assertEquals(1, result); + result = dMaaPMRPublisherQueue.addRecoverableMessages(messages); + assertEquals(1, result); + List<String> messageForPublishing = dMaaPMRPublisherQueue.getMessageForPublishing(); + assertNotNull(messageForPublishing); + int batchQueueRemainingSize = dMaaPMRPublisherQueue.getBatchQueueRemainingSize(); + assertEquals(2, batchQueueRemainingSize); + int recoveryQueueRemainingSize = dMaaPMRPublisherQueue.getRecoveryQueueRemainingSize(); + assertEquals(2, recoveryQueueRemainingSize); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/MRPublisher/DMaaPMRPublisherResponseImplTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/MRPublisher/DMaaPMRPublisherResponseImplTest.java new file mode 100755 index 0000000..fbc3ee3 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/MRPublisher/DMaaPMRPublisherResponseImplTest.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.dmaap.MRPublisher; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class DMaaPMRPublisherResponseImplTest { + @Test + public void testDMaaPMRPublisherResponseImpl() { + DMaaPMRPublisherResponseImpl dMaaPMRPublisherResponse + = new DMaaPMRPublisherResponseImpl(200, "msg", 2); + int responseCode = dMaaPMRPublisherResponse.getResponseCode(); + assertEquals(200, responseCode); + String responseMessage = dMaaPMRPublisherResponse.getResponseMessage(); + assertEquals("msg", responseMessage); + int pendingMessagesCount = dMaaPMRPublisherResponse.getPendingMessagesCount(); + assertEquals(2, pendingMessagesCount); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/MRSubcriber/DMaaPMRSubscriberImplTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/MRSubcriber/DMaaPMRSubscriberImplTest.java new file mode 100755 index 0000000..47ccb3b --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/dmaap/MRSubcriber/DMaaPMRSubscriberImplTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.dmaap.MRSubcriber; + +import org.junit.Test; + +import java.util.List; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertEquals; + +public class DMaaPMRSubscriberImplTest { + @Test + public void testFetchMessages() { + DMaaPMRSubscriberResponseImpl dMaaPMRSubscriberResponse + = new DMaaPMRSubscriberResponseImpl(1, "msg", null); + List<String> messages = dMaaPMRSubscriberResponse.getFetchedMessages(); + assertNotNull(messages); + String resMsg = dMaaPMRSubscriberResponse.getResponseMessage(); + assertNotNull(resMsg); + List<String> fetchedMessages = dMaaPMRSubscriberResponse.getFetchedMessages(); + assertNotNull(fetchedMessages); + int respCode = dMaaPMRSubscriberResponse.getResponseCode(); + assertEquals(1, respCode); + dMaaPMRSubscriberResponse = new DMaaPMRSubscriberResponseImpl(1, "msg"); + assertNotNull(dMaaPMRSubscriberResponse); + String toStr = dMaaPMRSubscriberResponse.toString(); + assertNotNull(toStr); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/DomainsTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/DomainsTest.java new file mode 100755 index 0000000..7185954 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/DomainsTest.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.domain; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class DomainsTest { + @Test + public void testDomains(){ + assertNotNull(Domains.DOMAIN_FAULT); + String value = Domains.DOMAIN_FAULT.getValue(); + assertNotNull(value); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/PrioritiesTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/PrioritiesTest.java new file mode 100755 index 0000000..1894562 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/PrioritiesTest.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.domain; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class PrioritiesTest { + @Test + public void testPriorities() { + assertNotNull(Priorities.HIGH); + String value = Priorities.HIGH.getValue(); + assertNotNull(value); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/SeverityTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/SeverityTest.java new file mode 100755 index 0000000..ca32b4a --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/SeverityTest.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.domain; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class SeverityTest { + @Test + public void testSeverityTest() { + assertNotNull(Severity.SEVERITY_CRITICAL); + String value = Severity.SEVERITY_CRITICAL.getValue(); + assertNotNull(value); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/StateTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/StateTest.java new file mode 100755 index 0000000..d25ff13 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/StateTest.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.domain; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class StateTest { + @Test + public void testState() { + assertNotNull(State.STATE_IN_SERVICE); + String value = State.STATE_IN_SERVICE.getValue(); + assertNotNull(value); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/SysLogSeverityTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/SysLogSeverityTest.java new file mode 100755 index 0000000..4ebb91b --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/SysLogSeverityTest.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.domain; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class SysLogSeverityTest { + @Test + public void testSysLogSeverity() { + assertNotNull(SysLogSeverity.SEVERITY_ALERT); + String value = SysLogSeverity.SEVERITY_ALERT.getValue(); + assertNotNull(value); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/TcaAlertActionTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/TcaAlertActionTest.java new file mode 100755 index 0000000..dbc3c88 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/TcaAlertActionTest.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.domain; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class TcaAlertActionTest { + @Test + public void testTcaAlertAction() { + assertNotNull(TcaAlertAction.CLEAR); + String value = TcaAlertAction.CLEAR.getValue(); + assertNotNull(value); + assertNotNull(TcaAlertType.CARD_ANOMALY); + value = TcaAlertType.CARD_ANOMALY.getValue(); + assertNotNull(value); + assertNotNull(TcaCounterCriticality.CRITICAL); + value = TcaCounterCriticality.CRITICAL.getValue(); + assertNotNull(value); + assertNotNull(TcaEventSeverity.SEVERITY_CRITICAL); + value = TcaEventSeverity.SEVERITY_CRITICAL.getValue(); + assertNotNull(value); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/VnfStatusTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/VnfStatusTest.java new file mode 100755 index 0000000..a0e2478 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/VnfStatusTest.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.domain; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class VnfStatusTest { + @Test + public void testVnfStatus() { + assertNotNull(VnfStatus.VFSTATUS_ACTIVE); + String value = VnfStatus.VFSTATUS_ACTIVE.getValue(); + assertNotNull(value); + } + +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/mappingconfig/EntryTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/mappingconfig/EntryTest.java index 0097658..00ed93a 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/mappingconfig/EntryTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/mappingconfig/EntryTest.java @@ -3,6 +3,7 @@ * ONAP : DCAE
* ================================================================================
* Copyright 2018-2019 TechMahindra
+ * Copyright (C) 2022 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.
@@ -52,9 +53,8 @@ public class EntryTest { assertEquals(entry.getAdditionalProperties(), additionalProperties);
assert (entry.toString() != null);
assert (entry.hashCode() != 0);
-
+ assert (!entry.equals(null));
assert (entry.equals(entry));
-
}
}
diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/mappingconfig/MapperConfigTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/mappingconfig/MapperConfigTest.java index a9cf2b0..7c3c170 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/mappingconfig/MapperConfigTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/mappingconfig/MapperConfigTest.java @@ -3,6 +3,7 @@ * ONAP : DCAE
* ================================================================================
* Copyright 2018-2019 TechMahindra
+ * Copyright (C) 2022 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.
@@ -47,7 +48,7 @@ public class MapperConfigTest { assertEquals(mapperConfig.getEntries(), entries);
assert (mapperConfig.toString() != null);
assert (mapperConfig.hashCode() != 0);
-
+ assert (!mapperConfig.equals(null));
assert (mapperConfig.equals(mapperConfig));
}
diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/VESAdapterInitializerTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/VESAdapterInitializerTest.java new file mode 100755 index 0000000..5aac110 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/VESAdapterInitializerTest.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.service; + +import org.junit.Test; + +import static org.junit.Assert.fail; + +public class VESAdapterInitializerTest { + @Test + public void testVESAdapterInitializer() { + try { + VesService vesService = new VesService(); + vesService.stop(); + vesService.start(); + } catch (Exception e) { + // expected case + return; + } + fail("Exception is not thrown"); + } +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/CollectorConfigPropertyRetrievalTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/CollectorConfigPropertyRetrievalTest.java new file mode 100755 index 0000000..2d8d860 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/CollectorConfigPropertyRetrievalTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.utils; + +import org.junit.Test; + +import java.net.URISyntaxException; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +public class CollectorConfigPropertyRetrievalTest { + @Test + public void testGetDmaapTopics() { + CollectorConfigPropertyRetrieval collectorConfigPropertyRetrieval = new CollectorConfigPropertyRetrieval(); + try { + collectorConfigPropertyRetrieval.getDmaapTopics("subsrciber", "publisher", "null"); + } catch (NullPointerException e) { + // expected case + return; + } + fail("Exception is not thrown"); + } + + @Test + public void testGetTopics() { + CollectorConfigPropertyRetrieval collectorConfigPropertyRetrieval = new CollectorConfigPropertyRetrieval(); + try { + collectorConfigPropertyRetrieval.getTopics("subsrciber", "publisher", "null"); + } catch (IllegalArgumentException e) { + // expected case + return; + } + fail("Exception is not thrown"); + } + + @Test + public void testGetTopicName() { + CollectorConfigPropertyRetrieval collectorConfigPropertyRetrieval = new CollectorConfigPropertyRetrieval(); + try { + String topicName = collectorConfigPropertyRetrieval.getTopicName("http://127.0.0.1"); + assertNotNull(topicName); + collectorConfigPropertyRetrieval.setDmaapConfig("http://127.0.0.1"); + } catch (URISyntaxException | NullPointerException e) { + // expected case + return; + } + fail("Exception is not thrown"); + } + +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/DmaapConfigTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/DmaapConfigTest.java new file mode 100755 index 0000000..ab6765b --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/DmaapConfigTest.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : DCAE + * ================================================================================ + * Copyright (C) 2022 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.universalvesadapter.utils; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class DmaapConfigTest { + + @Test + public void testSetDmaaphost() { + DmaapConfig dmaapConfig = new DmaapConfig(); + dmaapConfig.setDmaaphost("dmaapHost"); + String dmaaphost = dmaapConfig.getDmaaphost(); + assertEquals("dmaapHost", dmaaphost); + dmaapConfig.setDEFAULT_PORT_NUMBER(1234); + int default_port_number = dmaapConfig.getDEFAULT_PORT_NUMBER(); + assertEquals(1234, default_port_number); + dmaapConfig.setDMAAP_DEFAULT_CONSUMER_ID("1234"); + String dmaap_default_consumer_id = dmaapConfig.getDMAAP_DEFAULT_CONSUMER_ID(); + assertEquals("1234", dmaap_default_consumer_id); + dmaapConfig.setDMAAP_GROUP_PREFIX("abc"); + String dmaap_group_prefix = dmaapConfig.getDMAAP_GROUP_PREFIX(); + assertEquals("abc", dmaap_group_prefix); + dmaapConfig.setDMAAP_URI_PATH_PREFIX("prefix"); + String dmaap_uri_path_prefix = dmaapConfig.getDMAAP_URI_PATH_PREFIX(); + assertEquals("prefix", dmaap_uri_path_prefix); + dmaapConfig.setDEFAULT_CONTENT_TYPE("abc"); + String default_content_type = dmaapConfig.getDEFAULT_CONTENT_TYPE(); + assertEquals("abc", default_content_type); + dmaapConfig.setPollingInterval(2); + int pollingInterval = dmaapConfig.getPollingInterval(); + assertEquals(2, pollingInterval); + dmaapConfig.setsubscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME("msg"); + String msg = dmaapConfig.getsubscriberSUBSCRIBER_MSG_LIMIT_QUERY_PARAM_NAME(); + assertEquals("msg", msg); + dmaapConfig.setsubscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME("timeout"); + String timeout = dmaapConfig.getsubscriberSUBSCRIBER_TIMEOUT_QUERY_PARAM_NAME(); + assertEquals("timeout", timeout); + dmaapConfig.setsubscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX("prefix"); + String prefix = dmaapConfig.getsubscriberDEFAULT_SUBSCRIBER_GROUP_PREFIX(); + assertEquals("prefix", prefix); + dmaapConfig.setsubscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT(2); + int msgLimit = dmaapConfig.getsubscriberDEFAULT_SUBSCRIBER_MESSAGE_LIMIT(); + assertEquals(2, msgLimit); + dmaapConfig.setsubscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS(2); + int timeout_ms = dmaapConfig.getsubscriberDEFAULT_SUBSCRIBER_TIMEOUT_MS(); + assertEquals(2, timeout_ms); + dmaapConfig.setPublisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE(2); + int retries_on_close = dmaapConfig.getPublisherPUBLISHER_DELAY_MS_ON_RETRIES_ON_CLOSE(); + assertEquals(2, retries_on_close); + dmaapConfig.setPublisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE(2); + int flush_retries_on_close = dmaapConfig.getPublisherPUBLISHER_MAX_FLUSH_RETRIES_ON_CLOSE(); + assertEquals(2, flush_retries_on_close); + dmaapConfig.setPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE(2); + int max_recovery_queue_size = dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_RECOVERY_QUEUE_SIZE(); + assertEquals(2, max_recovery_queue_size); + dmaapConfig.setPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE(2); + int publisherDEFAULT_publisher_max_batch_size = dmaapConfig.getPublisherDEFAULT_PUBLISHER_MAX_BATCH_SIZE(); + assertEquals(2, publisherDEFAULT_publisher_max_batch_size); + dmaapConfig.setDEFAULT_PROTOCOL("HTTPS"); + String default_protocol = dmaapConfig.getDEFAULT_PROTOCOL(); + assertEquals("HTTPS", default_protocol); + dmaapConfig.setDEFAULT_USER_PASSWORD("abc"); + String default_user_password = dmaapConfig.getDEFAULT_USER_PASSWORD(); + assertEquals("abc", default_user_password); + dmaapConfig.setDEFAULT_USER_NAME("root"); + String default_user_name = dmaapConfig.getDEFAULT_USER_NAME(); + assertEquals("root", default_user_name); + } +} |