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.PrepareForTest;
37 import org.powermock.modules.junit4.PowerMockRunner;
39 import com.att.ajsc.beans.PropertiesMapBean;
40 import org.onap.dmaap.dmf.mr.CambriaApiException;
41 import org.onap.dmaap.dmf.mr.beans.DMaaPContext;
42 import org.onap.dmaap.dmf.mr.service.EventsService;
43 import org.onap.dmaap.dmf.mr.service.TransactionService;
44 import com.att.nsa.configs.ConfigDbException;
45 import com.att.nsa.security.ReadWriteSecuredResource.AccessDeniedException;
46 import com.att.aft.dme2.internal.jettison.json.JSONException;
47 import org.powermock.api.mockito.PowerMockito;
49 @RunWith(PowerMockRunner.class)
50 @PrepareForTest({ PropertiesMapBean.class })
51 public class TransactionRestServiceTest {
54 TransactionRestService transactionRestService;
57 private TransactionService transactionService;
60 DMaaPContext dmaapContext;
63 public void setUp() throws Exception {
64 MockitoAnnotations.initMocks(this);
68 public void tearDown() throws Exception {
73 public void testGetAllTransactionObjs() throws CambriaApiException {
75 transactionRestService.getAllTransactionObjs();
81 public void testGetTransactionObj() throws CambriaApiException {
83 transactionRestService.getTransactionObj("transactionId");
89 public void testGetAllTransactionObjsError() throws CambriaApiException {
92 PowerMockito.doThrow(new IOException()).when(transactionService).getAllTransactionObjs(dmaapContext);
93 } catch (ConfigDbException | IOException e) {
98 transactionRestService.getAllTransactionObjs();
99 } catch (CambriaApiException e) {
106 public void testGetTransactionObjError() {
109 PowerMockito.doThrow(new IOException()).when(transactionService).getTransactionObj(dmaapContext,
111 } catch (ConfigDbException | JSONException | IOException e) {
116 transactionRestService.getTransactionObj("transactionId");
117 } catch (CambriaApiException e) {