summaryrefslogtreecommitdiffstats
path: root/misc/env/src/test/java
diff options
context:
space:
mode:
authorSai Gandham <sg481n@att.com>2019-01-03 14:47:53 -0600
committerSai Gandham <sg481n@att.com>2019-01-04 09:00:04 -0600
commitf030908cc43f1af67e1e76d625d2e373a33399d6 (patch)
treed30f0961dde56453fec0106612a4d9a369875e6c /misc/env/src/test/java
parentaa4854d69e5bf9a9cc96e447e71035adf67fd36d (diff)
Add more junits misc env impl
Modified slot class Issue-ID: AAF-111 Change-Id: Iff3d8d1319110c56dba00a6c0f992473f94da4e1 Signed-off-by: Sai Gandham <sg481n@att.com>
Diffstat (limited to 'misc/env/src/test/java')
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_StoreImplTest.java (renamed from misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_StoreImplTest.java)0
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTrans.java292
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTransJaxb.java177
3 files changed, 469 insertions, 0 deletions
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_StoreImplTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_StoreImplTest.java
index db48345c..db48345c 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_StoreImplTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_StoreImplTest.java
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTrans.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTrans.java
new file mode 100644
index 00000000..572941f3
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTrans.java
@@ -0,0 +1,292 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * 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.aaf.misc.env.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.aaf.misc.env.Decryptor;
+import org.onap.aaf.misc.env.Encryptor;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.Slot;
+import org.onap.aaf.misc.env.StaticSlot;
+import org.onap.aaf.misc.env.StoreImpl;
+import org.onap.aaf.misc.env.TimeTaken;
+
+public class JU_AbsTrans {
+
+ @Mock
+ Env delegate;
+
+ @Mock
+ BasicEnv delegate1;
+
+ @Mock
+ LogTarget lt;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ }
+
+ class AbsTransImpl extends AbsTrans{
+
+ public AbsTransImpl(Env delegate) {
+ super(delegate);
+ // TODO Auto-generated constructor stub
+ }
+
+ public AbsTransImpl(BasicEnv delegate) {
+ super(delegate);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public Slot slot(String name) {
+ // TODO Auto-generated method stub
+ return new Slot(-1, "test");
+ }
+
+ @Override
+ public <T> T get(StaticSlot slot, T dflt) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String setProperty(String tag, String value) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getProperty(String tag) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getProperty(String tag, String deflt) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Decryptor decryptor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Encryptor encryptor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected TimeTaken newTimeTaken(String name, int flag) {
+ // TODO Auto-generated method stub
+ return new TimeTaken("nameTest", Env.XML) {
+
+ @Override
+ public void output(StringBuilder sb) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+ }
+
+ }
+
+ @Test
+ public void testFatal() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).fatal();
+ LogTarget lt = absTransObj.fatal();
+ assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testError() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).error();
+ LogTarget lt = absTransObj.error();
+ assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testAudit() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).audit();
+ LogTarget lt = absTransObj.audit();
+ assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testInit() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).init();
+ LogTarget lt = absTransObj.init();
+ assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testWarn() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).warn();
+ LogTarget lt = absTransObj.warn();
+ assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testInfo() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).info();
+ LogTarget lt = absTransObj.info();
+ assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testDebug() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).debug();
+ LogTarget lt = absTransObj.debug();
+ assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testTrace() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).trace();
+ LogTarget lt = absTransObj.trace();
+ assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testStart() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ TimeTaken lt = absTransObj.start("test",1);
+ assertEquals("nameTest", lt.name);
+ }
+
+ @Test
+ public void testCheckpint() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ absTransObj.checkpoint("test");
+ assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name);
+ }
+
+ @Test
+ public void testCheckpintAddFlag() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ absTransObj.checkpoint("test",1);
+ assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name);
+ }
+
+ @Test
+ public void testAuditTrailWithEmptyTrail() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).info();
+ Mockito.doReturn(true).when(lt).isLoggable();
+ absTransObj.auditTrail(1, new StringBuilder(), 1);
+ //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name);
+ }
+
+ @Test
+ public void testAuditTrail() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).info();
+ Mockito.doReturn(true).when(lt).isLoggable();
+ TimeTaken tt=absTransObj.newTimeTaken("test", 1);
+ absTransObj.trail.add(tt);
+ absTransObj.trail.add(tt);
+ absTransObj.trail.add(tt);
+ absTransObj.auditTrail(1, new StringBuilder(), 2);
+ //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name);
+ }
+
+ @Test
+ public void testAuditTrailLoggableFalse() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).info();
+ Mockito.doReturn(false).when(lt).isLoggable();
+ TimeTaken tt=absTransObj.newTimeTaken("test", 1);
+ absTransObj.trail.add(tt);
+ absTransObj.trail.add(tt);
+ absTransObj.trail.add(tt);
+ absTransObj.auditTrail(1, new StringBuilder(), 1);
+ //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name);
+ }
+
+ @Test
+ public void testAuditTrailNullSB() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).info();
+ Mockito.doReturn(true).when(lt).isLoggable();
+ TimeTaken tt=absTransObj.newTimeTaken("test", 1);
+ absTransObj.trail.add(tt);
+ absTransObj.trail.add(tt);
+ absTransObj.trail.add(tt);
+ absTransObj.auditTrail(1, null, 1);
+ //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name);
+ }
+
+ @Test
+ public void testAuditTrailEmpptyFlag() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate);
+ Mockito.doReturn(lt).when(delegate).info();
+ Mockito.doReturn(true).when(lt).isLoggable();
+ TimeTaken tt=absTransObj.newTimeTaken("test", 1);
+ absTransObj.trail.add(tt);
+ absTransObj.trail.add(tt);
+ absTransObj.trail.add(tt);
+ absTransObj.auditTrail(1, null, new int[] {});
+ //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name);
+ }
+
+ @Test
+ public void testPut() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate1);
+ try {
+ absTransObj.put(absTransObj.slot("test"), "test");
+ } catch(Exception e){
+ assertTrue(e instanceof NullPointerException);
+ }
+ }
+
+ @Test
+ public void testGet() {
+ AbsTransImpl absTransObj = new AbsTransImpl(delegate1);
+ try {
+ absTransObj.get(absTransObj.slot("test"), "test");
+ } catch(Exception e){
+ e.printStackTrace();
+ assertTrue(e instanceof NullPointerException);
+ }
+ }
+} \ No newline at end of file
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTransJaxb.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTransJaxb.java
new file mode 100644
index 00000000..98848804
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTransJaxb.java
@@ -0,0 +1,177 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * 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.aaf.misc.env.impl;
+
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import javax.xml.namespace.QName;
+import javax.xml.validation.Schema;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.aaf.misc.env.APIException;
+import org.onap.aaf.misc.env.DataFactory;
+import org.onap.aaf.misc.env.Decryptor;
+import org.onap.aaf.misc.env.Encryptor;
+import org.onap.aaf.misc.env.EnvJAXB;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.Slot;
+import org.onap.aaf.misc.env.StaticSlot;
+import org.onap.aaf.misc.env.TimeTaken;
+
+public class JU_AbsTransJaxb {
+
+ @Mock
+ EnvJAXB delegate;
+
+ @Mock
+ LogTarget lt;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ }
+
+ class AbsTransJAXBImpl extends AbsTransJAXB{
+
+ public AbsTransJAXBImpl(EnvJAXB env) {
+ super(env);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public String setProperty(String tag, String value) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getProperty(String tag) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getProperty(String tag, String deflt) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Decryptor decryptor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Encryptor encryptor() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Slot slot(String name) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> T get(StaticSlot slot, T dflt) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected TimeTaken newTimeTaken(String name, int flag) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+ }
+
+
+ @Test
+ public void testNewDataFactory() {
+ AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate);
+ DataFactory<Object> lt = null;
+
+ try {
+ Mockito.doReturn(lt).when(delegate).newDataFactory(new Class[] {AbsTransJAXB.class});
+ lt = absTransObj.newDataFactory(new Class[] {AbsTransJAXB.class});
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testNewDataFactorySchema() {
+ AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate);
+ DataFactory<Object> lt = null;
+ Schema schema = Mockito.mock(Schema.class);
+ try {
+ Mockito.doReturn(lt).when(delegate).newDataFactory(schema, new Class[] {AbsTransJAXB.class});
+ lt = absTransObj.newDataFactory(schema, new Class[] {AbsTransJAXB.class});
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testNewDataFactoryQname() {
+ AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate);
+ DataFactory<Object> lt = null;
+ QName schema = Mockito.mock(QName.class);
+ try {
+ Mockito.doReturn(lt).when(delegate).newDataFactory(schema, new Class[] {AbsTransJAXB.class});
+ lt = absTransObj.newDataFactory(schema, new Class[] {AbsTransJAXB.class});
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //assertTrue(lt instanceof LogTarget);
+ }
+
+ @Test
+ public void testNewDataFactorySchemaQname() {
+ AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate);
+ DataFactory<Object> lt = null;
+ QName qname = Mockito.mock(QName.class);
+ Schema schema = Mockito.mock(Schema.class);
+ try {
+ Mockito.doReturn(lt).when(delegate).newDataFactory(schema, qname,new Class[] {AbsTransJAXB.class});
+ lt = absTransObj.newDataFactory(schema, qname,new Class[] {AbsTransJAXB.class});
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //assertTrue(lt instanceof LogTarget);
+ }
+
+
+} \ No newline at end of file