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
21 package com.att.nsa.dmaap.service;
\r
23 import static org.junit.Assert.*;
\r
25 import java.io.IOException;
\r
26 import java.lang.reflect.InvocationTargetException;
\r
27 import java.lang.reflect.Method;
\r
29 import org.junit.After;
\r
30 import org.junit.Before;
\r
31 import org.junit.Test;
\r
32 import org.junit.runner.RunWith;
\r
33 import org.mockito.InjectMocks;
\r
34 import org.mockito.Mock;
\r
35 import org.mockito.MockitoAnnotations;
\r
36 import org.powermock.core.classloader.annotations.PrepareForTest;
\r
37 import org.powermock.modules.junit4.PowerMockRunner;
\r
39 import com.att.ajsc.beans.PropertiesMapBean;
\r
40 import org.onap.dmaap.dmf.mr.CambriaApiException;
\r
41 import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
\r
42 import org.onap.dmaap.dmf.mr.service.EventsService;
\r
43 import org.onap.dmaap.dmf.mr.service.TransactionService;
\r
44 import com.att.nsa.configs.ConfigDbException;
\r
45 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
\r
46 import com.att.aft.dme2.internal.jettison.json.JSONException;
\r
47 import org.powermock.api.mockito.PowerMockito;
\r
49 @RunWith(PowerMockRunner.class)
\r
50 @PrepareForTest({ PropertiesMapBean.class })
\r
51 public class TransactionRestServiceTest {
\r
54 TransactionRestService transactionRestService;
\r
57 private TransactionService transactionService;
\r
60 DMaaPContext dmaapContext;
\r
63 public void setUp() throws Exception {
\r
64 MockitoAnnotations.initMocks(this);
\r
68 public void tearDown() throws Exception {
\r
73 public void testGetAllTransactionObjs() throws CambriaApiException {
\r
75 transactionRestService.getAllTransactionObjs();
\r
81 public void testGetTransactionObj() throws CambriaApiException {
\r
83 transactionRestService.getTransactionObj("transactionId");
\r
89 public void testGetAllTransactionObjsError() throws CambriaApiException {
\r
92 PowerMockito.doThrow(new IOException()).when(transactionService).getAllTransactionObjs(dmaapContext);
\r
93 } catch (ConfigDbException | IOException e) {
\r
98 transactionRestService.getAllTransactionObjs();
\r
99 } catch (CambriaApiException e) {
\r
106 public void testGetTransactionObjError() {
\r
109 PowerMockito.doThrow(new IOException()).when(transactionService).getTransactionObj(dmaapContext,
\r
111 } catch (ConfigDbException | JSONException | IOException e) {
\r
116 transactionRestService.getTransactionObj("transactionId");
\r
117 } catch (CambriaApiException e) {
\r