2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
22 package com.att.nsa.cambria.service.impl;
\r
24 import static org.junit.Assert.*;
\r
26 import java.io.IOException;
\r
28 import com.att.nsa.cambria.beans.ApiKeyBean;
\r
29 import com.att.nsa.cambria.beans.DMaaPContext;
\r
30 import com.att.nsa.configs.ConfigDbException;
\r
31 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
\r
32 import com.att.nsa.security.db.NsaApiDb.KeyExistsException;
\r
34 import org.junit.After;
\r
35 import org.junit.Before;
\r
36 import org.junit.Test;
\r
38 public class ApiKeysServiceImplTest {
\r
41 public void setUp() throws Exception {
\r
45 public void tearDown() throws Exception {
\r
50 public void testGetAllApiKeys() {
\r
52 /* ApiKeysServiceImpl service = new ApiKeysServiceImpl();
\r
54 service.getAllApiKeys(new DMaaPContext());
\r
55 } catch (NullPointerException e) {
\r
56 // TODO Auto-generated catch block
\r
57 //e.printStackTrace();
\r
59 } catch (ConfigDbException e) {
\r
60 // TODO Auto-generated catch block
\r
61 e.printStackTrace();
\r
62 } catch (IOException e) {
\r
63 // TODO Auto-generated catch block
\r
64 e.printStackTrace();
\r
70 public void testGetApiKey() {
\r
72 ApiKeysServiceImpl service = new ApiKeysServiceImpl();
\r
74 service.getApiKey(new DMaaPContext(), "k35Hdw6Sde");
\r
75 } catch (NullPointerException e) {
\r
76 // TODO Auto-generated catch block
\r
77 //e.printStackTrace();
\r
79 } catch (ConfigDbException e) {
\r
80 // TODO Auto-generated catch block
\r
81 e.printStackTrace();
\r
82 } catch (IOException e) {
\r
83 // TODO Auto-generated catch block
\r
84 e.printStackTrace();
\r
90 public void testCreateApiKey() {
\r
92 /* ApiKeysServiceImpl service = new ApiKeysServiceImpl();
\r
94 service.createApiKey(new DMaaPContext(), new ApiKeyBean("hs647a@att.com", "testing apikey bean"));
\r
95 } catch (NullPointerException e) {
\r
96 // TODO Auto-generated catch block
\r
97 //e.printStackTrace();
\r
99 } catch (ConfigDbException e) {
\r
100 // TODO Auto-generated catch block
\r
101 e.printStackTrace();
\r
102 } catch (IOException e) {
\r
103 // TODO Auto-generated catch block
\r
104 e.printStackTrace();
\r
105 } catch (KeyExistsException e) {
\r
106 // TODO Auto-generated catch block
\r
107 e.printStackTrace();
\r
108 } catch(NoClassDefFoundError e) {
\r
115 public void testUpdateApiKey() {
\r
117 /* ApiKeysServiceImpl service = new ApiKeysServiceImpl();
\r
120 service.updateApiKey(new DMaaPContext(), "k6dWUcw4N", new ApiKeyBean("hs647a@att.com", "testing apikey bean"));
\r
121 } catch (NullPointerException e) {
\r
122 // TODO Auto-generated catch block
\r
123 //e.printStackTrace();
\r
125 } catch (ConfigDbException e) {
\r
126 // TODO Auto-generated catch block
\r
127 e.printStackTrace();
\r
128 } catch (IOException e) {
\r
129 // TODO Auto-generated catch block
\r
130 e.printStackTrace();
\r
131 } catch (AccessDeniedException e) {
\r
132 // TODO Auto-generated catch block
\r
133 e.printStackTrace();
\r
139 public void testDeleteApiKey() {
\r
141 /* ApiKeysServiceImpl service = new ApiKeysServiceImpl();
\r
144 service.deleteApiKey(new DMaaPContext(), "k6dWUcw4N");
\r
145 } catch (NullPointerException e) {
\r
146 // TODO Auto-generated catch block
\r
147 //e.printStackTrace();
\r
149 } catch (ConfigDbException e) {
\r
150 // TODO Auto-generated catch block
\r
151 e.printStackTrace();
\r
152 } catch (IOException e) {
\r
153 // TODO Auto-generated catch block
\r
154 e.printStackTrace();
\r
155 } catch (AccessDeniedException e) {
\r
156 // TODO Auto-generated catch block
\r
157 e.printStackTrace();
\r