diff --git a/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/jobs/LegalTagPublisherImplTest.java b/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/jobs/LegalTagPublisherImplTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ccbe72aec3f2c0432c9f130bef69324df1d98a0b --- /dev/null +++ b/provider/legal-azure/src/test/java/org/opengroup/osdu/legal/azure/jobs/LegalTagPublisherImplTest.java @@ -0,0 +1,69 @@ +// 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); + } +} diff --git a/provider/legal-azure/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/provider/legal-azure/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 0000000000000000000000000000000000000000..1f0955d450f0dc49ca715b1a0a88a5aa746ee11e --- /dev/null +++ b/provider/legal-azure/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline