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.assertTrue;
24 import static org.mockito.MockitoAnnotations.initMocks;
26 import org.junit.Before;
27 import org.junit.Test;
28 import org.mockito.Mockito;
29 import org.onap.aaf.misc.env.impl.EnvFactory;
31 public class JU_BaseDataFactory {
34 public void setUp() throws Exception {
39 public void testGenSchemaException() {
40 Store env = Mockito.mock(Store.class);
41 Mockito.doReturn("testdir").when(env).get(null, EnvFactory.DEFAULT_SCHEMA_DIR);
43 BaseDataFactory.genSchema(env, new String[] {});
44 } catch (APIException e) {
45 assertTrue(e.getLocalizedMessage().contains("does not exist. You can set this with"));
50 public void testGenSchemaXsdException() {
51 Store env = Mockito.mock(Store.class);
52 Mockito.doReturn(System.getProperty("user.dir")).when(env).get(null, EnvFactory.DEFAULT_SCHEMA_DIR);
53 String[] schemaFIles = new String[] {"../auth-client/src/main/xsd/aaf_2_0.xsd"};
55 BaseDataFactory.genSchema(env, schemaFIles);
56 } catch (APIException e) {
57 assertTrue(e.getLocalizedMessage().contains("for schema validation"));
62 public void testGenSchemaNoException() {
63 Store env = Mockito.mock(Store.class);
64 Mockito.doReturn(System.getProperty("user.dir")).when(env).get(null, EnvFactory.DEFAULT_SCHEMA_DIR);
65 String[] schemaFIles = new String[] {"../../auth-client/src/main/xsd/aaf_2_0.xsd"};
67 BaseDataFactory.genSchema(env, schemaFIles);
68 } catch (APIException e) {
74 public void testGetQName() {
75 String[] schemaFIles = new String[] {"../../auth-client/src/main/xsd/aaf_2_0.xsd"};
77 BaseDataFactory.getQName(Api.class);
78 } catch (APIException e) {
79 assertTrue(e.getLocalizedMessage().contains("package-info does not have an XmlSchema annotation"));