DaanHoogland commented on code in PR #6957:
URL: https://github.com/apache/cloudstack/pull/6957#discussion_r1159823690


##########
server/src/test/java/com/cloud/network/NetworkServiceImplTest.java:
##########
@@ -713,4 +724,50 @@ public void testCheckAndUpdateNetworkResetSuccess() {
         Assert.assertNull(networkVO.getIp6Dns1());
         Assert.assertNull(networkVO.getIp6Dns2());
     }
+    @Test
+    public void 
validateIfServiceOfferingIsActiveAndSystemVmTypeIsDomainRouterTestMustThrowInvalidParameterValueExceptionWhenServiceOfferingIsNull()
 {
+        doReturn(null).when(serviceOfferingDaoMock).findById(anyLong());
+
+        String expectedMessage = String.format("Could not find specified 
service offering [%s].", 1l);
+        InvalidParameterValueException assertThrows = 
Assert.assertThrows(expectedException, () -> {
+            
service.validateIfServiceOfferingIsActiveAndSystemVmTypeIsDomainRouter(1l);
+        });
+
+        Assert.assertEquals(expectedMessage, assertThrows.getMessage());
+    }
+
+    @Test
+    public void 
validateIfServiceOfferingIsActiveAndSystemVmTypeIsDomainRouterTestMustThrowInvalidParameterValueExceptionWhenServiceOfferingStateIsInactive()
 {
+        
doReturn(serviceOfferingVoMock).when(serviceOfferingDaoMock).findById(anyLong());
+        
doReturn(ServiceOffering.State.Inactive).when(serviceOfferingVoMock).getState();
+
+        String expectedMessage = String.format("The specified service offering 
[%s] is inactive.", serviceOfferingVoMock);
+        InvalidParameterValueException assertThrows = 
Assert.assertThrows(expectedException, () -> {
+            
service.validateIfServiceOfferingIsActiveAndSystemVmTypeIsDomainRouter(1l);
+        });
+
+        Assert.assertEquals(expectedMessage, assertThrows.getMessage());
+    }
+
+    @Test
+    public void 
validateIfServiceOfferingIsActiveAndSystemVmTypeIsDomainRouterTestMustThrowInvalidParameterValueExceptionWhenSystemVmTypeIsNotDomainRouter()
 {
+        
doReturn(serviceOfferingVoMock).when(serviceOfferingDaoMock).findById(anyLong());
+        
doReturn(ServiceOffering.State.Active).when(serviceOfferingVoMock).getState();
+        
doReturn(VirtualMachine.Type.ElasticLoadBalancerVm.toString()).when(serviceOfferingVoMock).getSystemVmType();
+
+        String expectedMessage = String.format("The specified service offering 
[%s] is of type [%s]. Virtual routers can only be created with service offering 
of type [%s].",
+                serviceOfferingVoMock, 
serviceOfferingVoMock.getSystemVmType(), 
VirtualMachine.Type.DomainRouter.toString().toLowerCase());
+        InvalidParameterValueException assertThrows = 
Assert.assertThrows(expectedException, () -> {
+            
service.validateIfServiceOfferingIsActiveAndSystemVmTypeIsDomainRouter(1l);
+        });
+
+        Assert.assertEquals(expectedMessage, assertThrows.getMessage());
+    }
+
+    @Test
+    public void 
validateIfServiceOfferingIsActiveAndSystemVmTypeIsDomainRouterTestMustNotThrowInvalidParameterValueExceptionWhenSystemVmTypeIsDomainRouter()
 {
+        NetworkServiceImpl networkServiceImplMock = 
mock(NetworkServiceImpl.class);
+
+        
networkServiceImplMock.validateIfServiceOfferingIsActiveAndSystemVmTypeIsDomainRouter(1l);

Review Comment:
   a bit after the fact, but what is the intention of this test @stephankruggg 
? It seems to test if a mock is callable/being called...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to