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