Remove this useless eq(...) invocation
[so.git] / adapters / mso-adapter-utils / src / test / java / org / onap / so / openstack / utils / MsoCommonUtilsTest.java
index 5cf7c86..160201f 100644 (file)
@@ -3,6 +3,7 @@
  * ONAP - SO
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2022 - Samsung Electronics. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -69,6 +70,7 @@ public class MsoCommonUtilsTest extends BaseTest {
         Mockito.when(openstackRequest.path()).thenReturn("/test");
         // TODO:Must try a real connection
         assertNull(commonUtils.executeAndRecordOpenstackRequest(openstackRequest));
+        assertNull(commonUtils.executeAndRecordOpenstackRequest(openstackRequest, true));
     }
 
     @Test
@@ -78,6 +80,7 @@ public class MsoCommonUtilsTest extends BaseTest {
         doThrow(OpenStackResponseException.class).when(openstackRequest).execute();
 
         commonUtils.executeAndRecordOpenstackRequest(openstackRequest);
+        commonUtils.executeAndRecordOpenstackRequest(openstackRequest, true);
     }
 
     @Test
@@ -86,7 +89,7 @@ public class MsoCommonUtilsTest extends BaseTest {
 
         doThrow(OpenStackConnectException.class).when(openstackRequest).execute();
 
-        commonUtils.executeAndRecordOpenstackRequest(openstackRequest);
+        commonUtils.executeAndRecordOpenstackRequest(openstackRequest, true);
     }
 
     @Test
@@ -98,19 +101,19 @@ public class MsoCommonUtilsTest extends BaseTest {
         MsoException me = commonUtils.keystoneErrorToMsoException(openStackConnectException, "ContextError");
 
         assertTrue(me instanceof MsoIOException);
-        assertTrue("connect".equals(me.getMessage()));
+        assertEquals("connect", me.getMessage());
 
 
         MsoException me2 = commonUtils.keystoneErrorToMsoException(openStackResponseException, "ContextError");
         assertTrue(me2 instanceof MsoOpenstackException);
-        assertTrue("ContextError".equals(me2.getContext()));
-        assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory()));
+        assertEquals("ContextError", me2.getContext());
+        assertEquals(MsoExceptionCategory.OPENSTACK, me2.getCategory());
 
 
         OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class);
         Error error = mapper.readValue(new File(RESOURCE_PATH + "Error.json"), Error.class);
 
-        doReturn(error).when(openStackResponse).getErrorEntity(eq(Error.class));
+        doReturn(error).when(openStackResponse).getErrorEntity(Error.class);
 
         openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse);
 
@@ -129,19 +132,19 @@ public class MsoCommonUtilsTest extends BaseTest {
         MsoException me = commonUtils.heatExceptionToMsoException(openStackConnectException, "ContextError");
 
         assertTrue(me instanceof MsoIOException);
-        assertTrue("connect".equals(me.getMessage()));
+        assertEquals("connect", me.getMessage());
 
 
         MsoException me2 = commonUtils.heatExceptionToMsoException(openStackResponseException, "ContextError");
         assertTrue(me2 instanceof MsoOpenstackException);
-        assertTrue("ContextError".equals(me2.getContext()));
-        assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory()));
+        assertEquals("ContextError", me2.getContext());
+        assertEquals(MsoExceptionCategory.OPENSTACK, me2.getCategory());
 
 
         OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class);
         Explanation explanation = mapper.readValue(new File(RESOURCE_PATH + "Explanation.json"), Explanation.class);
 
-        doReturn(explanation).when(openStackResponse).getErrorEntity(eq(Explanation.class));
+        doReturn(explanation).when(openStackResponse).getErrorEntity(Explanation.class);
 
         openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse);
 
@@ -161,18 +164,18 @@ public class MsoCommonUtilsTest extends BaseTest {
         MsoException me = commonUtils.neutronExceptionToMsoException(openStackConnectException, "ContextError");
 
         assertTrue(me instanceof MsoIOException);
-        assertTrue("connect".equals(me.getMessage()));
+        assertEquals("connect", me.getMessage());
 
         MsoException me2 = commonUtils.neutronExceptionToMsoException(openStackResponseException, "ContextError");
         assertTrue(me2 instanceof MsoOpenstackException);
-        assertTrue("ContextError".equals(me2.getContext()));
-        assertTrue(MsoExceptionCategory.OPENSTACK.equals(me2.getCategory()));
+        assertEquals("ContextError", me2.getContext());
+        assertEquals(MsoExceptionCategory.OPENSTACK, me2.getCategory());
 
 
         OpenStackResponse openStackResponse = Mockito.mock(OpenStackResponse.class);
         NeutronError explanation = mapper.readValue(new File(RESOURCE_PATH + "NeutronError.json"), NeutronError.class);
 
-        doReturn(explanation).when(openStackResponse).getErrorEntity(eq(NeutronError.class));
+        doReturn(explanation).when(openStackResponse).getErrorEntity(NeutronError.class);
 
         openStackResponseException = new OpenStackResponseException("response", 501, openStackResponse);
 
@@ -188,8 +191,8 @@ public class MsoCommonUtilsTest extends BaseTest {
         MsoException me = commonUtils.runtimeExceptionToMsoException(re, "ContextError");
 
         assertTrue(me instanceof MsoAdapterException);
-        assertTrue("ContextError".equals(me.getContext()));
-        assertTrue(MsoExceptionCategory.INTERNAL.equals(me.getCategory()));
+        assertEquals("ContextError", me.getContext());
+        assertEquals(MsoExceptionCategory.INTERNAL, me.getCategory());
     }
 
     @Test
@@ -200,6 +203,7 @@ public class MsoCommonUtilsTest extends BaseTest {
 
         assertTrue(msoException instanceof MsoAdapterException);
         assertEquals("ContextError", msoException.getContext());
-        assertTrue(MsoExceptionCategory.INTERNAL.equals(msoException.getCategory()));
+        assertEquals(MsoExceptionCategory.INTERNAL, msoException.getCategory());
     }
 }
+