2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.dmaap.service;
23 import static org.junit.Assert.*;
25 import java.io.IOException;
26 import java.lang.reflect.InvocationTargetException;
27 import java.lang.reflect.Method;
29 import org.junit.After;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.junit.runner.RunWith;
33 import org.mockito.InjectMocks;
34 import org.mockito.Mock;
35 import org.mockito.MockitoAnnotations;
36 import org.powermock.core.classloader.annotations.PowerMockIgnore;
37 import org.powermock.core.classloader.annotations.PrepareForTest;
38 import org.powermock.modules.junit4.PowerMockRunner;
40 import com.att.ajsc.beans.PropertiesMapBean;
41 import org.onap.dmaap.dmf.mr.CambriaApiException;
42 import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
43 import org.onap.dmaap.dmf.mr.service.EventsService;
44 import org.onap.dmaap.dmf.mr.service.TransactionService;
45 import com.att.nsa.configs.ConfigDbException;
46 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
47 import com.att.aft.dme2.internal.jettison.json.JSONException;
48 import org.powermock.api.mockito.PowerMockito;
50 @RunWith(PowerMockRunner.class)
51 @PowerMockIgnore("jdk.internal.reflect.*")
52 @PrepareForTest({ PropertiesMapBean.class })
53 public class TransactionRestServiceTest {
56 TransactionRestService transactionRestService;
59 private TransactionService transactionService;
62 DMaaPContext dmaapContext;
65 public void setUp() throws Exception {
66 MockitoAnnotations.initMocks(this);
70 public void tearDown() throws Exception {
75 public void testGetAllTransactionObjs() throws CambriaApiException {
77 transactionRestService.getAllTransactionObjs();
83 public void testGetTransactionObj() throws CambriaApiException {
85 transactionRestService.getTransactionObj("transactionId");
91 public void testGetAllTransactionObjsError() throws CambriaApiException {
94 PowerMockito.doThrow(new IOException()).when(transactionService).getAllTransactionObjs(dmaapContext);
95 } catch (ConfigDbException | IOException e) {
100 transactionRestService.getAllTransactionObjs();
101 } catch (CambriaApiException e) {
108 public void testGetTransactionObjError() {
111 PowerMockito.doThrow(new IOException()).when(transactionService).getTransactionObj(dmaapContext,
113 } catch (ConfigDbException | JSONException | IOException e) {
118 transactionRestService.getTransactionObj("transactionId");
119 } catch (CambriaApiException e) {