summaryrefslogtreecommitdiffstats
path: root/misc/rosetta/src
diff options
context:
space:
mode:
authorSai Gandham <sg481n@att.com>2019-01-08 09:07:04 -0600
committerSai Gandham <sg481n@att.com>2019-01-08 09:07:21 -0600
commit46b2ef2f40805fa4c5887e8f490a4bc80996e00c (patch)
treef498282ff9e65f1e5ac4f2bfd4d230f67256503b /misc/rosetta/src
parent975ef94a1ca2efc6199462bf33abbc11ef3213c8 (diff)
Add more junits Rosetta module
Issue-ID: AAF-111 Change-Id: Ie87eaf796a17bdfc9551b903200b4edb99c0ede8 Signed-off-by: Sai Gandham <sg481n@att.com>
Diffstat (limited to 'misc/rosetta/src')
-rw-r--r--misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java5
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/Api.java373
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java663
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java98
-rw-r--r--misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java49
5 files changed, 1188 insertions, 0 deletions
diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java
index fa29dcdc..bb590e1c 100644
--- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java
+++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java
@@ -57,6 +57,11 @@ public class RosettaData<T> implements Data<T>{
inType = df.getInType();
outType = df.getOutType(); // take defaults
}
+
+ //Added for junits
+ void setSaved(Saved saved) {
+ this.saved = saved;
+ }
// // @Override
public RosettaData<T> in(TYPE rosettaType) {
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/Api.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/Api.java
new file mode 100644
index 00000000..20744355
--- /dev/null
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/Api.java
@@ -0,0 +1,373 @@
+/**
+ * ============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====================================================
+ *
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2018.12.09 at 10:14:23 PM IST
+//
+
+
+package org.onap.aaf.misc.rosetta.env;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="route" maxOccurs="unbounded" minOccurs="0">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="meth" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="path" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="param" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="desc" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="comments" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="contentType" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="expected" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ * &lt;element name="explicitErr" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "route"
+})
+@XmlRootElement(name = "api")
+public class Api {
+
+ protected List<Api.Route> route;
+
+ /**
+ * Gets the value of the route property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the route property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getRoute().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Api.Route }
+ *
+ *
+ */
+ public List<Api.Route> getRoute() {
+ if (route == null) {
+ route = new ArrayList<Api.Route>();
+ }
+ return this.route;
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="meth" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="path" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="param" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="desc" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="comments" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="contentType" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="expected" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ * &lt;element name="explicitErr" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "meth",
+ "path",
+ "param",
+ "desc",
+ "comments",
+ "contentType",
+ "expected",
+ "explicitErr"
+ })
+ public static class Route {
+
+ @XmlElement(required = true)
+ protected String meth;
+ @XmlElement(required = true)
+ protected String path;
+ protected List<String> param;
+ @XmlElement(required = true)
+ protected String desc;
+ protected List<String> comments;
+ protected List<String> contentType;
+ protected int expected;
+ @XmlElement(type = Integer.class)
+ protected List<Integer> explicitErr;
+
+ /**
+ * Gets the value of the meth property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMeth() {
+ return meth;
+ }
+
+ /**
+ * Sets the value of the meth property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMeth(String value) {
+ this.meth = value;
+ }
+
+ /**
+ * Gets the value of the path property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * Sets the value of the path property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setPath(String value) {
+ this.path = value;
+ }
+
+ /**
+ * Gets the value of the param property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the param property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getParam().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getParam() {
+ if (param == null) {
+ param = new ArrayList<String>();
+ }
+ return this.param;
+ }
+
+ /**
+ * Gets the value of the desc property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getDesc() {
+ return desc;
+ }
+
+ /**
+ * Sets the value of the desc property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setDesc(String value) {
+ this.desc = value;
+ }
+
+ /**
+ * Gets the value of the comments property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the comments property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getComments().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getComments() {
+ if (comments == null) {
+ comments = new ArrayList<String>();
+ }
+ return this.comments;
+ }
+
+ /**
+ * Gets the value of the contentType property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the contentType property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContentType().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getContentType() {
+ if (contentType == null) {
+ contentType = new ArrayList<String>();
+ }
+ return this.contentType;
+ }
+
+ /**
+ * Gets the value of the expected property.
+ *
+ */
+ public int getExpected() {
+ return expected;
+ }
+
+ /**
+ * Sets the value of the expected property.
+ *
+ */
+ public void setExpected(int value) {
+ this.expected = value;
+ }
+
+ /**
+ * Gets the value of the explicitErr property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the explicitErr property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getExplicitErr().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Integer }
+ *
+ *
+ */
+ public List<Integer> getExplicitErr() {
+ if (explicitErr == null) {
+ explicitErr = new ArrayList<Integer>();
+ }
+ return this.explicitErr;
+ }
+
+ }
+
+}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java
new file mode 100644
index 00000000..cbf7e2dc
--- /dev/null
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java
@@ -0,0 +1,663 @@
+/**
+ * ============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.rosetta.env;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+
+import javax.xml.bind.JAXBException;
+
+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.Data;
+import org.onap.aaf.misc.env.Data.TYPE;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.TimeTaken;
+import org.onap.aaf.misc.env.jaxb.JAXBmar;
+import org.onap.aaf.misc.env.jaxb.JAXBumar;
+import org.onap.aaf.misc.rosetta.InXML;
+import org.onap.aaf.misc.rosetta.Marshal;
+import org.onap.aaf.misc.rosetta.Out;
+import org.onap.aaf.misc.rosetta.OutXML;
+import org.onap.aaf.misc.rosetta.ParseException;
+import org.onap.aaf.misc.rosetta.Saved;
+
+public class JU_RosettaData {
+
+ @Mock
+ Env env;
+
+ @Mock
+ RosettaDF df;
+
+ @Mock
+ JAXBmar bmar;
+
+ @Mock
+ Saved saved;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ }
+
+ @Test
+ public void testLoad() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+ StringReader sr= Mockito.mock(StringReader.class);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(sr,(Writer)null,inxml);
+
+ rosettaObj = rosettaObj.load(sr);
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testLoadException() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ rosettaObj = rosettaObj.load(Mockito.mock(StringReader.class));
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("NullPointerException"));
+ }
+ }
+
+ @Test
+ public void testLoadIs() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+ InputStream sr= Mockito.mock(InputStream.class);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(new InputStreamReader(sr),(Writer)null,inxml);
+
+ rosettaObj = rosettaObj.load(sr);
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testLoadIsException() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ rosettaObj = rosettaObj.load(Mockito.mock(InputStream.class));
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("NullPointerException"));
+ }
+ }
+
+ @Test
+ public void testLoadStr() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml);
+
+ rosettaObj = rosettaObj.load("test");
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ @Test
+ public void testLoadStrJson() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.JSON);
+ rosettaObj.setSaved(saved);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml);
+
+ rosettaObj = rosettaObj.load("test");
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ @Test
+ public void testLoadStrException() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ rosettaObj = rosettaObj.load("test");
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("NullPointerException"));
+ }
+ }
+
+ @Test
+ public void testLoadT() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ df.jaxMar = Mockito.mock(JAXBmar.class);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml);
+
+ rosettaObj = rosettaObj.load(bmar);
+ df.marshal = null;
+ rosettaObj = rosettaObj.load(bmar);
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testLoadTMarshalNull() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ df.jaxMar = Mockito.mock(JAXBmar.class);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml);
+ df.marshal = Mockito.mock(Marshal.class);;
+ rosettaObj = rosettaObj.load(bmar);
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testLoadTException() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ rosettaObj = rosettaObj.load(bmar);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("NullPointerException"));
+ }
+ }
+
+ @Test
+ public void testGetEvents() {
+ RosettaData rosettaObj = new RosettaData(env, df);
+ Saved saved = rosettaObj.getEvents();
+ assertEquals("Rosetta Saved", saved.logName());
+ }
+
+ @Test
+ public void testAsObject() {
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+ Mockito.doReturn(outxml).when(df).getOut(Data.TYPE.XML);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ df.jaxMar = Mockito.mock(JAXBmar.class);
+ df.jaxUmar = Mockito.mock(JAXBumar.class);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",0);
+ LogTarget lt = Mockito.mock(LogTarget.class);
+ Mockito.doReturn( lt).when(env).debug();
+ Mockito.doNothing().when(saved).extract(null,new StringWriter(),saved);
+ Mockito.doReturn(bmar).when(df.jaxUmar).unmarshal(lt,"");
+
+ bmar = rosettaObj.asObject();
+
+ } catch (APIException | IOException | ParseException | JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAsObjectException() {
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+ Mockito.doReturn(outxml).when(df).getOut(Data.TYPE.XML);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ df.jaxMar = Mockito.mock(JAXBmar.class);
+ df.jaxUmar = Mockito.mock(JAXBumar.class);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",0);
+ LogTarget lt = Mockito.mock(LogTarget.class);
+ Mockito.doReturn( lt).when(env).debug();
+ Mockito.doThrow(new IOException("test Exception")).when(saved).extract(null,new StringWriter(),saved);
+ Mockito.doThrow(new JAXBException("test Exception")).when(df.jaxUmar).unmarshal(lt,"");
+
+ bmar = rosettaObj.asObject();
+
+ } catch (APIException | IOException | ParseException | JAXBException e) {
+ assertTrue(e.getMessage().contains("test Exception"));
+ }
+ }
+
+ @Test
+ public void testAsString() {
+ TYPE type = TYPE.XML;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2);
+
+ String retVal = rosettaObj.asString();
+ assertTrue("".equals(retVal));
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAsStringJson() {
+ TYPE type = TYPE.JSON;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.JSON);
+ rosettaObj.setSaved(saved);
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4);
+
+ String retVal = rosettaObj.asString();
+ assertTrue("".equals(retVal));
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ @Test
+ public void testToXml() {
+ TYPE type = TYPE.XML;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml);
+
+ rosettaObj = rosettaObj.load("test");
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2);
+ RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(OutputStream.class));
+
+ } catch (APIException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testToJson() {
+ TYPE type = TYPE.JSON;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.JSON);
+ rosettaObj.setSaved(saved);
+
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml);
+
+ rosettaObj = rosettaObj.load("test");
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4);
+ RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(OutputStream.class));
+
+ } catch (APIException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testTo() {
+ TYPE type = TYPE.XML;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2);
+ RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(OutputStream.class));
+
+ } catch (APIException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testToWriterXml() {
+ TYPE type = TYPE.XML;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml);
+
+ rosettaObj = rosettaObj.load("test");
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2);
+ RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(StringWriter.class));
+
+ } catch (APIException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testToWriterJson() {
+ TYPE type = TYPE.JSON;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.JSON);
+ rosettaObj.setSaved(saved);
+
+ try {
+ InXML inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON);
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env);
+ Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml);
+
+ rosettaObj = rosettaObj.load("test");
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4);
+ RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(StringWriter.class));
+
+ } catch (APIException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testToWriter() {
+ TYPE type = TYPE.XML;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj = rosettaObj.in(Data.TYPE.XML);
+ rosettaObj.setSaved(saved);
+
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2);
+ RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(StringWriter.class));
+
+ } catch (APIException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testGetTypeClass() {
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ rosettaObj.getTypeClass();
+ }
+
+ @Test
+ public void testDirect() {
+ TYPE type = TYPE.XML;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2);
+ rosettaObj.direct(Mockito.mock(InputStream.class), Mockito.mock(OutputStream.class));
+ } catch (APIException | IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testDirectException() {
+ TYPE type = TYPE.XML;
+ Mockito.doReturn(type).when(df).getOutType();
+ Mockito.doReturn(type).when(df).getInType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ InXML inxml = null;
+
+ inxml = Mockito.mock(InXML.class);
+ Mockito.doReturn(inxml).when(df).getIn(type);
+
+
+ StringReader is = Mockito.mock(StringReader.class);
+ StringWriter os= Mockito.mock(StringWriter.class);
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2);
+ Mockito.doThrow( new IOException("testException")).when(outxml).extract(is, os, inxml, true);
+
+ rosettaObj.direct(is,os, true);
+ } catch (APIException | IOException | ParseException e) {
+ // TODO Auto-generated catch block
+ assertTrue(e.getMessage().contains("testException"));
+ }
+ }
+
+ @Test
+ public void testDirectT() {
+ TYPE type = TYPE.XML;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2);
+
+ df.jaxMar = Mockito.mock(JAXBmar.class);
+ LogTarget lt = Mockito.mock(LogTarget.class);
+ Mockito.doReturn( lt).when(env).debug();
+ Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true);
+
+ rosettaObj.direct(bmar, Mockito.mock(StringWriter.class), true);
+ df.marshal =Mockito.mock(Marshal.class);;
+ rosettaObj.direct(bmar, Mockito.mock(StringWriter.class), true);
+ } catch (APIException | IOException | JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testDirectTOS() {
+ TYPE type = TYPE.XML;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2);
+
+ df.jaxMar = Mockito.mock(JAXBmar.class);
+ LogTarget lt = Mockito.mock(LogTarget.class);
+ Mockito.doReturn( lt).when(env).debug();
+ Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true);
+
+ rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true);
+ df.marshal =Mockito.mock(Marshal.class);;
+ rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true);
+ } catch (APIException | IOException | JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testDirectTOSJson() {
+ TYPE type = TYPE.JSON;
+ Mockito.doReturn(type).when(df).getOutType();
+ RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df);
+ try {
+ Out outxml = Mockito.mock(OutXML.class);
+ Mockito.doReturn(outxml).when(df).getOut(type);
+ Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON);
+ Mockito.doReturn("test").when(outxml).logName();
+ Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4);
+
+ df.jaxMar = Mockito.mock(JAXBmar.class);
+ LogTarget lt = Mockito.mock(LogTarget.class);
+ Mockito.doReturn( lt).when(env).debug();
+ Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true);
+
+ rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true);
+ } catch (APIException | IOException | JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+
+}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java
new file mode 100644
index 00000000..b5889b45
--- /dev/null
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java
@@ -0,0 +1,98 @@
+/**
+ * ============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.rosetta.env;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.applet.Applet;
+import java.util.Properties;
+
+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.Env;
+import org.onap.aaf.misc.env.jaxb.JAXBmar;
+import org.onap.aaf.misc.rosetta.Saved;
+
+public class JU_RosettaEnv {
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ }
+
+ @Test
+ public void testNewDataFactoryClass() {
+ RosettaEnv rosettaObj = new RosettaEnv();
+ try {
+ Object retVal = rosettaObj.newDataFactory(Api.class);
+ assertTrue(retVal instanceof RosettaDF);
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testNewDataFactorySchema() {
+ RosettaEnv rosettaObj = new RosettaEnv(Mockito.mock(Applet.class),"test");
+ try {
+ Object retVal = rosettaObj.newDataFactory(Mockito.mock(Schema.class),Api.class);
+ assertTrue(retVal instanceof RosettaDF);
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testNewDataFactoryQname() {
+ RosettaEnv rosettaObj = new RosettaEnv(new String[] {"test"});
+ rosettaObj = new RosettaEnv(Mockito.mock(Properties.class));
+ try {
+ Object retVal = rosettaObj.newDataFactory(Mockito.mock(QName.class),Api.class);
+ assertTrue(retVal instanceof RosettaDF);
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testNewDataFactoryQnameSchema() {
+ RosettaEnv rosettaObj = new RosettaEnv("test", new String[] {"test"});
+ rosettaObj = new RosettaEnv("test", Mockito.mock(Properties.class));
+ try {
+ Object retVal = rosettaObj.newDataFactory(Mockito.mock(Schema.class),Mockito.mock(QName.class),Api.class);
+ assertTrue(retVal instanceof RosettaDF);
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java
new file mode 100644
index 00000000..c28e83d5
--- /dev/null
+++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java
@@ -0,0 +1,49 @@
+/**
+ * ============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.rosetta.marshal;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aaf.misc.env.jaxb.JAXBumar;
+
+public class JU_FieldBlob {
+
+ class FieldBlobImpl extends FieldBlob{
+
+ public FieldBlobImpl(String name) {
+ super(name);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ protected byte[] data(Object t) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ }
+ @Test
+ public void testData() {
+ FieldBlob<JAXBumar> obj = new FieldBlobImpl("test");
+ obj.data(Mockito.mock(JAXBumar.class), new StringBuilder());
+ }
+
+}