Skip to content
Snippets Groups Projects
Commit a8bc4c67 authored by Aalekh Jain's avatar Aalekh Jain
Browse files

Added init method for unit testing for `LegalTagPublisherImpl`

parent 262b1548
No related branches found
No related tags found
1 merge request!61Improve code coverage
// Copyright © Microsoft Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.legal.azure.jobs;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.microsoft.azure.servicebus.Message;
import com.microsoft.azure.servicebus.MessageBody;
import com.microsoft.azure.servicebus.TopicClient;
import com.microsoft.azure.servicebus.primitives.ServiceBusException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.model.legal.StatusChangedTags;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class)
public class LegalTagPublisherImplTest {
private static final String DATA_PARTITION_WITH_FALLBACK_ACCOUNT_ID = "data-partition-account-id";
private static final String CORRELATION_ID = "correlation-id";
private static final String USER_EMAIL = "user@email.com";
private JaxRsDpsLog logger;
private TopicClient topicClient;
@Mock
private DpsHeaders headers;
@InjectMocks
private LegalTagPublisherImpl sut;
@Before
public void init() throws ServiceBusException, InterruptedException {
topicClient = mock(TopicClient.class);
logger = mock(JaxRsDpsLog.class);
doNothing().when(topicClient).send(any());
doNothing().when(logger).error(anyString(), (Exception) any());
doNothing().when(logger).info(anyString());
doReturn(DATA_PARTITION_WITH_FALLBACK_ACCOUNT_ID).when(headers).getPartitionIdWithFallbackToAccountId();
doReturn(CORRELATION_ID).when(headers).getCorrelationId();
doReturn(USER_EMAIL).when(headers).getUserEmail();
sut = new LegalTagPublisherImpl(topicClient, logger);
}
}
mock-maker-inline
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment