Skip to content
Snippets Groups Projects
Commit 381e8672 authored by Solomon Ayalew's avatar Solomon Ayalew
Browse files

Revert deleted test classes

parent 5e25b58d
No related branches found
No related tags found
2 merge requests!491Upgrade service to spring 6 and Spring-boot 3,!490Solxget spring6 2
Pipeline #248999 failed
// Copyright © Amazon Web Services
//
// 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.notification.provider.aws.queue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockedConstruction;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.opengroup.osdu.core.aws.ssm.K8sLocalParameterProvider;
import org.opengroup.osdu.notification.provider.aws.utils.SQSUtils;
import org.powermock.reflect.Whitebox;
@RunWith(MockitoJUnitRunner.class)
public class NotificationRetrySQSHandlerTest {
@Mock
private NotificationQueueService notificationRetryQueueService;
@Mock
private SQSUtils sqsUtil;
@InjectMocks
NotificationRetrySQSHandler notificationRetrySQSHandler;
private static MockedConstruction<K8sLocalParameterProvider> mockedConstruction;
@BeforeClass
public static void setup() {
mockedConstruction = Mockito.mockConstruction(K8sLocalParameterProvider.class,
(mock, context) -> {
Mockito.when(mock.getParameterAsString("notification-retry-sqs-url")).thenReturn(
"test-sqs-url");
});
}
@AfterClass
public static void close() {
mockedConstruction.close();
}
@Before
public void initTest() {
Whitebox.setInternalState(notificationRetrySQSHandler, "region", "us-east-1");
}
@Test(expected = InterruptedException.class)
public void processNotifications_interruptedException() throws Exception {
when(sqsUtil.getMessages(any(), anyString(), anyInt(), anyInt())).thenAnswer((t) -> {
throw new InterruptedException("Test Interrupted");
});
notificationRetrySQSHandler.init();
}
}
// Copyright © Amazon Web Services
//
// 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.notification.provider.aws.queue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockedConstruction;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.opengroup.osdu.core.aws.ssm.K8sLocalParameterProvider;
import org.opengroup.osdu.notification.provider.aws.utils.SQSUtils;
import org.powermock.reflect.Whitebox;
@RunWith(MockitoJUnitRunner.class)
public class NotificationSQSHandlerTest {
@Mock
private NotificationQueueService notificationQueueService;
@Mock
private SQSUtils sqsUtil;
@InjectMocks
NotificationSQSHandler notificationSQSHandler;
private static MockedConstruction<K8sLocalParameterProvider> mockedConstruction;
@BeforeClass
public static void setup() {
mockedConstruction = Mockito.mockConstruction(K8sLocalParameterProvider.class,
(mock, context) -> {
Mockito.when(mock.getParameterAsString("notification-sqs-url")).thenReturn(
"test-sqs-retry-url");
});
}
@AfterClass
public static void close() {
mockedConstruction.close();
}
@Before
public void initTest() {
Whitebox.setInternalState(notificationSQSHandler, "region", "us-east-1");
}
@Test(expected = InterruptedException.class)
public void processNotifications_interruptedException() throws Exception {
when(sqsUtil.getMessages(any(), anyString(), anyInt(), anyInt())).thenAnswer((t) -> {
throw new InterruptedException("Test Interrupted");
});
notificationSQSHandler.init();
}
}
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