2 * ============LICENSE_START===================================================
3 * SPARKY (AAI UI service)
4 * ============================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=====================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.onap.aai.sparky.editattributes;
28 import static org.hamcrest.Matchers.containsInAnyOrder;
29 import static org.hamcrest.Matchers.empty;
30 import static org.junit.Assert.assertThat;
33 import java.nio.file.Paths;
34 import java.util.List;
36 import org.junit.BeforeClass;
37 import org.junit.Test;
38 import org.onap.aai.sparky.editattributes.UserAuthorizationReader;
41 * The Class TestUserAuthorizationReader.
43 public class TestUserAuthorizationReader {
45 private static File userAuthFile;
46 private static File userAuthFileEmpty;
49 * Sets the up before class.
51 * @throws Exception the exception
54 public static void setUpBeforeClass() throws Exception {
55 userAuthFile = Paths.get(TestData.USER_AUTH_FILE.getFilename()).toFile();
56 userAuthFileEmpty = Paths.get(TestData.USER_AUTH_FILE_EMPTY.getFilename()).toFile();
65 "src/test/resources/user-auth-reader/authorized-users.config"), USER_AUTH_FILE_EMPTY(
66 "src/test/resources/user-auth-reader/authorized-users-empty.config");
68 private String filename;
71 * Instantiates a new test data.
73 * @param filename the filename
75 TestData(String filename) {
76 this.filename = filename;
79 public String getFilename() {
88 * @throws Exception the exception
91 public void testGetUsers() throws Exception {
92 UserAuthorizationReader userAuthorizationReader = new UserAuthorizationReader(userAuthFile);
95 List<String> userList = userAuthorizationReader.getUsers();
97 assertThat(userList, containsInAnyOrder("user1", "user2 user3", "user4"));
101 * Test get users passing empty config.
103 * @throws Exception the exception
106 public void testGetUsersPassingEmptyConfig() throws Exception {
107 UserAuthorizationReader userConfigReader = new UserAuthorizationReader(userAuthFileEmpty);
109 List<String> userList = userConfigReader.getUsers();
111 assertThat(userList, empty());