2 * ===============================LICENSE_START======================================
4 * ================================================================================
5 * Copyright © 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.dcae.apod.analytics.cdap.plugins.batch.sink.dmaap;
23 import org.apache.hadoop.mapreduce.TaskAttemptContext;
24 import org.junit.Before;
25 import org.junit.Test;
26 import org.mockito.Mockito;
27 import org.onap.dcae.apod.analytics.cdap.plugins.BaseAnalyticsCDAPPluginsUnitTest;
28 import org.onap.dcae.apod.analytics.dmaap.service.publisher.DMaaPMRPublisher;
30 import java.util.Arrays;
32 import static org.mockito.Mockito.times;
35 * @author Rajiv Singla . Creation Date: 1/30/2017.
37 public class DMaaPMRRecordWriterTest extends BaseAnalyticsCDAPPluginsUnitTest {
39 private DMaaPMRPublisher publisher;
40 private DMaaPMRRecordWriter dMaaPMRRecordWriter;
43 public void before() {
44 publisher = Mockito.mock(DMaaPMRPublisher.class);
45 dMaaPMRRecordWriter = new DMaaPMRRecordWriter(publisher);
49 public void testWrite() throws Exception {
50 final String testMessage = "test Message";
51 dMaaPMRRecordWriter.write(testMessage, null);
52 Mockito.verify(publisher, times(1)).publish(Arrays.asList(testMessage));
56 public void testClose() throws Exception {
57 final TaskAttemptContext taskAttemptContext = Mockito.mock(TaskAttemptContext.class);
58 dMaaPMRRecordWriter.close(taskAttemptContext);
59 Mockito.verify(publisher, times(1)).flush();