diff options
author | m.kowalski3 <m.kowalski3@partner.samsung.com> | 2019-05-13 09:07:41 +0200 |
---|---|---|
committer | m.kowalski3 <m.kowalski3@partner.samsung.com> | 2019-06-05 08:58:48 +0200 |
commit | 25398f36c6b36b85ce521a42f6754c78a38fe552 (patch) | |
tree | 53f00f898d8da06029c3fac4097f0df1b5bac8d9 /src/test | |
parent | 61ef2fb62f1818da16a48d75c7a3e0824e39e970 (diff) |
Improve test coverage in DcaeEvent
Change-Id: Iead99d97d7ad2a803ef67cdf8a7eebaca76c60bd
Issue-ID: CLAMP-355
Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com>
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java | 74 | ||||
-rw-r--r-- | src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java | 2 |
2 files changed, 75 insertions, 1 deletions
diff --git a/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java b/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java new file mode 100644 index 000000000..315e656d7 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/model/DcaeEventTest.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 Samsung. 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.clamp.clds.model; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; +import javax.ws.rs.BadRequestException; +import java.util.Arrays; + +public class DcaeEventTest { + + @Test + public void testGetCldsActionId() { + //given + DcaeEvent dcaeEvent = new DcaeEvent(); + dcaeEvent.setEvent(DcaeEvent.EVENT_CREATED); + dcaeEvent.setResourceUUID("1"); + dcaeEvent.setServiceUUID("2"); + + //when + String cldsAction = dcaeEvent.getCldsActionCd(); + dcaeEvent.setInstances(Arrays.asList(new CldsModelInstance())); + //then + assertEquals(CldsEvent.ACTION_CREATE, cldsAction); + + //when + dcaeEvent.setEvent(DcaeEvent.EVENT_DEPLOYMENT); + //then + assertEquals(CldsEvent.ACTION_DEPLOY, dcaeEvent.getCldsActionCd()); + + //when + dcaeEvent.setInstances(null); + //then + assertEquals(CldsEvent.ACTION_DEPLOY, dcaeEvent.getCldsActionCd()); + + //when + dcaeEvent.setEvent(DcaeEvent.EVENT_UNDEPLOYMENT); + //then + assertEquals(CldsEvent.ACTION_UNDEPLOY, dcaeEvent.getCldsActionCd()); + + } + + @Test(expected = BadRequestException.class) + public void shouldReturnBadRequestException() { + //given + DcaeEvent dcaeEvent = new DcaeEvent(); + dcaeEvent.setResourceUUID("1"); + dcaeEvent.setServiceUUID("2"); + //when + dcaeEvent.setEvent("BadEvent"); + //then + dcaeEvent.getCldsActionCd(); + } +} diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index ed912831e..d451b0670 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -27,7 +27,6 @@ package org.onap.clamp.loop; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Matchers.any; import java.io.IOException; import java.util.ArrayList; @@ -65,6 +64,7 @@ import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.annotation.Rollback; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; |