2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Huawei 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.openecomp.mso.client.dmaap;
23 import static org.assertj.core.api.Assertions.assertThat;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.Mockito.spy;
26 import static org.mockito.Mockito.when;
28 import java.io.IOException;
29 import java.util.Arrays;
30 import java.util.Optional;
31 import org.junit.Test;
32 import org.openecomp.mso.client.sdno.dmaap.PnfReadyEventConsumer;
34 public class PnfReadyEventConsumerTest {
36 private static final String CORRELATION_ID = "correlation_id_test";
38 private static final String JSON_WITH_CORRELATION_ID = " {\"pnfRegistrationFields\": {\n"
39 + " \"correlationId\": \"correlation_id_test\"\n"
43 public void eventIsFoundForGivenCorrelationId2() throws Exception {
44 PnfReadyEventConsumerForTesting testedObjectSpy = spy(new PnfReadyEventConsumerForTesting(CORRELATION_ID));
45 Consumer consumerMock = mock(Consumer.class);
46 when(testedObjectSpy.getConsumer()).thenReturn(consumerMock);
47 when(consumerMock.fetch()).thenReturn(Arrays.asList(JSON_WITH_CORRELATION_ID));
48 testedObjectSpy.consume();
49 assertThat(testedObjectSpy.continuePolling()).isFalse();
52 // TODO this is temporary class, when methods are defined, it will be deleted
53 private class PnfReadyEventConsumerForTesting extends PnfReadyEventConsumer {
55 public PnfReadyEventConsumerForTesting(String correlationId) throws IOException {
60 public String getUserName(){
61 return "userNameTest";
64 public String getPassword(){
68 public String getTopic(){
72 public Optional<String> getHost(){
73 return Optional.of("http://localhost");
76 public boolean isFailure(String message) {
80 public String getRequestId() {