aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2019-08-23 11:12:50 +0200
committerTomasz Golabek <tomasz.golabek@nokia.com>2019-08-23 13:53:22 +0000
commit986de50ace41e45664c69a615f4880102197b31a (patch)
tree7f082cc0407234fe4bc8ab22d91ec56171106cde
parent3c3782f1622ddc60c9e17dd6b166e476c38f001b (diff)
increasing test coverage in common-app-api exception catalog
Issue-ID: SDC-2326 Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> Change-Id: I0dd6bc60c88acbcf1b3755627a7b10b874a549ba
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentExceptionTest.java55
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteReferencedObjectExceptionTest.java40
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/FunctionalExceptionTest.java54
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/IndexingServiceExceptionTest.java54
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/InvalidArgumentExceptionTest.java54
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/NotFoundExceptionTest.java54
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/OkResponseInfoTest.java43
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/PolicyExceptionTest.java54
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/ServiceExceptionTest.java54
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/exception/VersionConflictExceptionTest.java45
10 files changed, 507 insertions, 0 deletions
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentExceptionTest.java
new file mode 100644
index 0000000000..3f1eaab17c
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteLastApplicationEnvironmentExceptionTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class DeleteLastApplicationEnvironmentExceptionTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void validateOneArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ expectedException.expect(DeleteLastApplicationEnvironmentException.class);
+ expectedException.expectMessage(testMessage);
+
+ throw new DeleteLastApplicationEnvironmentException(testMessage);
+ }
+
+ @Test
+ public void validateTwoArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ final String testThrowableMessage = "test throwable";
+ final Throwable testThrowable = new Throwable(testThrowableMessage);
+ expectedException.expect(DeleteLastApplicationEnvironmentException.class);
+ expectedException.expectMessage(testMessage);
+ expectedException.expectCause(is(testThrowable));
+
+ throw new DeleteLastApplicationEnvironmentException(testMessage, testThrowable);
+ }
+
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteReferencedObjectExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteReferencedObjectExceptionTest.java
new file mode 100644
index 0000000000..4952207824
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/DeleteReferencedObjectExceptionTest.java
@@ -0,0 +1,40 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class DeleteReferencedObjectExceptionTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void validateOneArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ expectedException.expect(DeleteReferencedObjectException.class);
+ expectedException.expectMessage(testMessage);
+
+ throw new DeleteReferencedObjectException(testMessage);
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/FunctionalExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/FunctionalExceptionTest.java
new file mode 100644
index 0000000000..3fa9d19f21
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/FunctionalExceptionTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class FunctionalExceptionTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void validateOneArgConstructorsThrowsCorrectException() throws Exception {
+ final String testMessage = "test error message";
+ expectedException.expect(FunctionalException.class);
+ expectedException.expectMessage(testMessage);
+
+ throw new FunctionalException(testMessage);
+ }
+
+ @Test
+ public void validateTwoArgConstructorsThrowsCorrectException() throws Exception {
+ final String testMessage = "test error message";
+ final String testThrowableMessage = "test throwable";
+ final Throwable testThrowable = new Throwable(testThrowableMessage);
+ expectedException.expect(FunctionalException.class);
+ expectedException.expectMessage(testMessage);
+ expectedException.expectCause(is(testThrowable));
+
+ throw new FunctionalException(testMessage, testThrowable);
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/IndexingServiceExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/IndexingServiceExceptionTest.java
new file mode 100644
index 0000000000..bbca082d44
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/IndexingServiceExceptionTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class IndexingServiceExceptionTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void validateOneArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ expectedException.expect(IndexingServiceException.class);
+ expectedException.expectMessage(testMessage);
+
+ throw new IndexingServiceException(testMessage);
+ }
+
+ @Test
+ public void validateTwoArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ final String testThrowableMessage = "test throwable";
+ final Throwable testThrowable = new Throwable(testThrowableMessage);
+ expectedException.expect(IndexingServiceException.class);
+ expectedException.expectMessage(testMessage);
+ expectedException.expectCause(is(testThrowable));
+
+ throw new IndexingServiceException(testMessage, testThrowable);
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/InvalidArgumentExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/InvalidArgumentExceptionTest.java
new file mode 100644
index 0000000000..c1770a3450
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/InvalidArgumentExceptionTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class InvalidArgumentExceptionTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void validateOneArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ expectedException.expect(InvalidArgumentException.class);
+ expectedException.expectMessage(testMessage);
+
+ throw new InvalidArgumentException(testMessage);
+ }
+
+ @Test
+ public void validateTwoArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ final String testThrowableMessage = "test throwable";
+ final Throwable testThrowable = new Throwable(testThrowableMessage);
+ expectedException.expect(InvalidArgumentException.class);
+ expectedException.expectMessage(testMessage);
+ expectedException.expectCause(is(testThrowable));
+
+ throw new InvalidArgumentException(testMessage, testThrowable);
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/NotFoundExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/NotFoundExceptionTest.java
new file mode 100644
index 0000000000..5086613d12
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/NotFoundExceptionTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class NotFoundExceptionTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void validateOneArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ expectedException.expect(NotFoundException.class);
+ expectedException.expectMessage(testMessage);
+
+ throw new NotFoundException(testMessage);
+ }
+
+ @Test
+ public void validateTwoArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ final String testThrowableMessage = "test throwable";
+ final Throwable testThrowable = new Throwable(testThrowableMessage);
+ expectedException.expect(NotFoundException.class);
+ expectedException.expectMessage(testMessage);
+ expectedException.expectCause(is(testThrowable));
+
+ throw new NotFoundException(testMessage, testThrowable);
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/OkResponseInfoTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/OkResponseInfoTest.java
new file mode 100644
index 0000000000..274dcbf183
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/OkResponseInfoTest.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+
+public class OkResponseInfoTest {
+
+ @Test
+ public void validateArgConstructorsThrowsCorrectException() {
+ final String testMessageId = "test message id";
+ final String testMessage = "test error message: %0, %1";
+ final String[] testVariables = {"testVariable01", "testVariable02"};
+ final String expectedMessage = "test error message: testVariable01, testVariable02";
+
+ OkResponseInfo okResponseInfo = new OkResponseInfo(testMessageId, testMessage, testVariables);
+ assertEquals(okResponseInfo.getMessageId(),testMessageId);
+ assertEquals(okResponseInfo.getFormattedErrorMessage(),expectedMessage);
+ assertArrayEquals(okResponseInfo.getVariables(),testVariables);
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/PolicyExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/PolicyExceptionTest.java
new file mode 100644
index 0000000000..2de3335958
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/PolicyExceptionTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class PolicyExceptionTest {
+
+ @Test
+ public void validateNoArgConstructorsThrowsCorrectException() {
+
+ PolicyException okResponseInfo = new PolicyException();
+
+ assertNull(okResponseInfo.getMessageId());
+ assertNull(okResponseInfo.getFormattedErrorMessage());
+ assertNull(okResponseInfo.getVariables());
+
+ }
+
+ @Test
+ public void validateArgConstructorsThrowsCorrectException() {
+ final String testMessageId = "test message id";
+ final String testMessage = "test error message: %0, %1";
+ final String[] testVariables = {"testVariable01", "testVariable02"};
+ final String expectedMessage = "test error message: testVariable01, testVariable02";
+
+ PolicyException okResponseInfo = new PolicyException(testMessageId, testMessage, testVariables);
+ assertEquals(okResponseInfo.getMessageId(),testMessageId);
+ assertEquals(okResponseInfo.getFormattedErrorMessage(),expectedMessage);
+ assertArrayEquals(okResponseInfo.getVariables(),testVariables);
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/ServiceExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/ServiceExceptionTest.java
new file mode 100644
index 0000000000..a3c9933473
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/ServiceExceptionTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class ServiceExceptionTest {
+
+ @Test
+ public void validateNoArgConstructorsThrowsCorrectException() {
+
+ ServiceException okResponseInfo = new ServiceException();
+
+ assertNull(okResponseInfo.getMessageId());
+ assertNull(okResponseInfo.getFormattedErrorMessage());
+ assertNull(okResponseInfo.getVariables());
+
+ }
+
+ @Test
+ public void validateArgConstructorsThrowsCorrectException() {
+ final String testMessageId = "test message id";
+ final String testMessage = "test error message: %0, %1";
+ final String[] testVariables = {"testVariable01", "testVariable02"};
+ final String expectedMessage = "test error message: testVariable01, testVariable02";
+
+ ServiceException okResponseInfo = new ServiceException(testMessageId, testMessage, testVariables);
+ assertEquals(okResponseInfo.getMessageId(),testMessageId);
+ assertEquals(okResponseInfo.getFormattedErrorMessage(),expectedMessage);
+ assertArrayEquals(okResponseInfo.getVariables(),testVariables);
+ }
+}
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/exception/VersionConflictExceptionTest.java b/common-app-api/src/test/java/org/openecomp/sdc/exception/VersionConflictExceptionTest.java
new file mode 100644
index 0000000000..92096e59bd
--- /dev/null
+++ b/common-app-api/src/test/java/org/openecomp/sdc/exception/VersionConflictExceptionTest.java
@@ -0,0 +1,45 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2019 Nokia. 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.openecomp.sdc.exception;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.hamcrest.core.Is.is;
+
+public class VersionConflictExceptionTest {
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void validateTwoArgConstructorsThrowsCorrectException() {
+ final String testMessage = "test error message";
+ final String testThrowableMessage = "test throwable";
+ final Throwable testThrowable = new Throwable(testThrowableMessage);
+ expectedException.expect(VersionConflictException.class);
+ expectedException.expectMessage(testMessage);
+ expectedException.expectCause(is(testThrowable));
+
+ throw new VersionConflictException(testMessage, testThrowable);
+ }
+}