2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
21 package org.onap.aaf.misc.env.jaxb;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNull;
25 import static org.junit.Assert.assertTrue;
26 import static org.mockito.MockitoAnnotations.initMocks;
28 import java.util.List;
29 import java.util.Properties;
31 import javax.xml.namespace.QName;
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.Mock;
37 import org.mockito.Mockito;
38 import org.mockito.runners.MockitoJUnitRunner;
39 import org.onap.aaf.misc.env.Env;
40 import org.onap.aaf.misc.env.LogTarget;
41 import org.onap.aaf.misc.env.Slot;
42 import org.onap.aaf.misc.env.StaticSlot;
43 import org.onap.aaf.misc.env.StoreImpl;
44 import org.onap.aaf.misc.env.TimeTaken;
46 @RunWith(MockitoJUnitRunner.class)
47 public class JU_StoreImplTest {
55 TimeTaken tt,ttstringify;
62 tt=Mockito.mock(TimeTaken.class);
63 Mockito.doReturn(tt).when(env).start("JAXB Marshal", Env.XML);
64 Mockito.doNothing().when(tt).done();
65 logT = Mockito.mock(LogTarget.class);
66 Mockito.doReturn(logT).when(env).debug();
70 public void testPropsFromArgs() {
71 StoreImpl bdfObj = new StoreImpl();
72 bdfObj = new StoreImpl("");
73 bdfObj.propsFromArgs(null, new String[] {"test"});
74 bdfObj.propsFromArgs("test", new String[] {"test","te=st","test=1"});
79 public void testMorePropsConstructor() {
80 Properties props = Mockito.mock(Properties.class);
81 new StoreImpl(null,props);
82 StoreImpl bdfObj = new StoreImpl("test",props);
86 public void testMorePropsFileNOtExists() {
87 Properties props = Mockito.mock(Properties.class);
88 Mockito.doReturn("test").when(props).getProperty("test");
89 StoreImpl bdfObj = new StoreImpl("test",props);
93 public void testMorePropsExists() {
94 Properties props = Mockito.mock(Properties.class);
95 Mockito.doReturn(System.getProperty("user.dir")+"/src/test/java/org/onap/aaf/misc/env/JU_StoreImplTest.java").when(props).getProperty("test");
96 StoreImpl bdfObj = new StoreImpl("test",props);
100 public void testNewTransState() {
101 StoreImpl bdfObj = new StoreImpl(null, new String[] {});
102 bdfObj.newTransState();
106 public void testSlot() {
107 StoreImpl bdfObj = new StoreImpl("test", new String[] {});
108 Slot slot = bdfObj.slot(null);
109 assertEquals(slot.toString(),"=0");
110 slot = bdfObj.slot("test");
111 assertEquals(slot.toString(),"test=1");
115 public void testExistingSlot() {
116 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
117 Slot retVal = bdfObj.existingSlot("test");
122 public void testExistingSlotNames() {
123 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
124 List<String> retVal = bdfObj.existingSlotNames();
125 assertTrue(retVal.size()==0);
129 public void testGet() {
130 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
131 Object retVal = bdfObj.get(new StaticSlot(1,"test"),qname);
132 assertTrue(retVal instanceof QName);
136 public void testGetSlot() {
137 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
138 Object retVal = bdfObj.get(new StaticSlot(1,"test"));
143 public void testExistingStaticSlotNames() {
144 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
145 List<String> retVal = bdfObj.existingStaticSlotNames();
146 assertTrue(retVal.size()==1);