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;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNull;
25 import static org.junit.Assert.assertSame;
26 import static org.junit.Assert.assertTrue;
27 import static org.mockito.MockitoAnnotations.initMocks;
30 import java.util.List;
31 import java.util.Properties;
33 import javax.xml.namespace.QName;
35 import org.junit.Before;
36 import org.junit.Test;
37 import org.junit.runner.RunWith;
38 import org.mockito.Mock;
39 import org.mockito.Mockito;
40 import org.mockito.runners.MockitoJUnitRunner;
42 @RunWith(MockitoJUnitRunner.class)
43 public class JU_StoreImplTest {
51 TimeTaken tt,ttstringify;
58 tt=Mockito.mock(TimeTaken.class);
59 Mockito.doReturn(tt).when(env).start("JAXB Marshal", Env.XML);
60 Mockito.doNothing().when(tt).done();
61 logT = Mockito.mock(LogTarget.class);
62 Mockito.doReturn(logT).when(env).debug();
66 public void testPropsFromArgs() {
67 StoreImpl bdfObj = new StoreImpl();
68 bdfObj = new StoreImpl("");
69 bdfObj.propsFromArgs(null, new String[] {"test"});
70 bdfObj.propsFromArgs("test", new String[] {"test","te=st","test=1"});
75 public void testMorePropsConstructor() {
76 Properties props = Mockito.mock(Properties.class);
77 new StoreImpl(null,props);
78 StoreImpl bdfObj = new StoreImpl("test",props);
82 public void testMorePropsFileNOtExists() {
83 Properties props = Mockito.mock(Properties.class);
84 Mockito.doReturn("test").when(props).getProperty("test");
85 StoreImpl bdfObj = new StoreImpl("test",props);
89 public void testMorePropsExists() {
90 Properties props = Mockito.mock(Properties.class);
91 Mockito.doReturn(System.getProperty("user.dir")+"/src/test/java/org/onap/aaf/misc/env/JU_StoreImplTest.java").when(props).getProperty("test");
92 StoreImpl bdfObj = new StoreImpl("test",props);
96 public void testNewTransState() {
97 StoreImpl bdfObj = new StoreImpl(null, new String[] {});
98 bdfObj.newTransState();
102 public void testSlot() {
103 StoreImpl bdfObj = new StoreImpl("test", new String[] {});
104 Slot slot = bdfObj.slot(null);
105 assertEquals(slot.toString(),"=0");
106 slot = bdfObj.slot("test");
107 assertEquals(slot.toString(),"test=1");
111 public void testExistingSlot() {
112 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
113 Slot retVal = bdfObj.existingSlot("test");
118 public void testExistingSlotNames() {
119 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
120 List<String> retVal = bdfObj.existingSlotNames();
121 assertTrue(retVal.size()==0);
125 public void testGet() {
126 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
127 Object retVal = bdfObj.get(new StaticSlot(1,"test"),qname);
128 assertTrue(retVal instanceof QName);
132 public void testGetSlot() {
133 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
134 Object retVal = bdfObj.get(new StaticSlot(1,"test"));
139 public void testExistingStaticSlotNames() {
140 StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
141 List<String> retVal = bdfObj.existingStaticSlotNames();
142 assertTrue(retVal.size()==1);