summaryrefslogtreecommitdiffstats
path: root/src/test/java/org
diff options
context:
space:
mode:
authorm.kowalski3 <m.kowalski3@partner.samsung.com>2019-06-11 14:53:03 +0200
committerm.kowalski3 <m.kowalski3@partner.samsung.com>2019-06-13 10:52:07 +0200
commitc13c9dd3e79565a7c909f76a48fe3d02388cef43 (patch)
treef54a5c523bb044541095e54ae6bb4de82ae74ef1 /src/test/java/org
parentf08ec4e6a1f7ca4a19c68c73ce2d689deb01eba1 (diff)
Improve unit tests for BaseCopyAction
Issue-ID: SDC-2327 Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com> Change-Id: I5c41e8330d63a7c232deacf69ac4afa52197ffba
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/BaseCopyActionTest.java132
1 files changed, 111 insertions, 21 deletions
diff --git a/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/BaseCopyActionTest.java b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/BaseCopyActionTest.java
index 1af2b15..65b5618 100644
--- a/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/BaseCopyActionTest.java
+++ b/src/test/java/org/onap/sdc/dcae/composition/restmodels/ruleeditor/BaseCopyActionTest.java
@@ -1,30 +1,120 @@
-package org.onap.sdc.dcae.composition.restmodels.ruleeditor;
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * 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============================================
+ * ===================================================================
+ *
+ */
-import org.junit.Test;
+package org.onap.sdc.dcae.composition.restmodels.ruleeditor;
import static com.google.code.beanmatchers.BeanMatchers.*;
import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
public class BaseCopyActionTest {
- @Test
- public void shouldHaveValidGettersAndSetters() {
- assertThat(BaseCopyAction.class, hasValidGettersAndSetters());
- }
-
- @Test
- public void checkEquals() {
- assertThat(BaseCopyAction.class, hasValidBeanEquals());
- }
-
- @Test
- public void testHasValidConstructor() {
- assertThat(BaseCopyAction.class, hasValidBeanConstructor());
- }
-
- @Test
- public void checkHashCodeFor() {
- assertThat(BaseCopyAction.class, hasValidBeanHashCodeFor());
- }
+ private final static String FROM = "from";
+ private final static String REGEX = ".example";
+ private final static String TARGET = "${\"12345\"}";
+ private BaseCopyAction baseCopyAction;
+ private BaseCopyAction otherBaseCopyAction;
+
+ @Before
+ public void setup() {
+ baseCopyAction = new BaseCopyAction();
+ baseCopyAction.setFrom(FROM);
+ otherBaseCopyAction = new BaseCopyAction();
+ otherBaseCopyAction.setFrom(FROM);
+ }
+
+
+ @Test
+ public void shouldHaveValidGettersAndSetters() {
+ assertThat(BaseCopyAction.class, hasValidGettersAndSetters());
+ }
+
+ @Test
+ public void checkEquals() {
+ assertThat(BaseCopyAction.class, hasValidBeanEquals());
+ }
+
+ @Test
+ public void testHasValidConstructor() {
+ assertThat(BaseCopyAction.class, hasValidBeanConstructor());
+ }
+
+ @Test
+ public void checkHashCodeFor() {
+ assertThat(BaseCopyAction.class, hasValidBeanHashCodeFor());
+ }
+
+ @Test
+ public void testFromValue() {
+ //when
+ String from = baseCopyAction.fromValue();
+
+ //then
+ assertEquals(FROM, from);
+ }
+
+ @Test
+ public void testRegexValue() {
+ //given
+ baseCopyAction.getFrom().setRegex(REGEX);
+
+ //when
+ String regex = baseCopyAction.regexValue();
+
+ //then
+ assertEquals(REGEX, regex);
+ }
+
+
+ @Test
+ public void referencesTargetShouldReturnTrue() {
+ //given
+ baseCopyAction.getFrom().setValue(TARGET);
+ otherBaseCopyAction.setTarget(TARGET);
+
+ //then
+ assertTrue(baseCopyAction.referencesTarget(otherBaseCopyAction));
+ }
+
+ @Test
+ public void referencesTargetShouldReturnFalse() {
+ //given
+ otherBaseCopyAction.setTarget("${\"otherMock\"}");
+
+ //then
+ assertFalse(baseCopyAction.referencesTarget(otherBaseCopyAction));
+ }
+
+ @Test
+ public void testStrippedTarget() {
+ //given
+ baseCopyAction.setTarget(TARGET);
+
+ //when
+ String strippedTarget = baseCopyAction.strippedTarget();
+
+ //then
+ assertEquals("\"12345\"", strippedTarget);
+ }
} \ No newline at end of file