erickalendra commented on code in PR #10686:
URL: https://github.com/apache/cloudstack/pull/10686#discussion_r2037803726
##########
server/src/test/java/com/cloud/network/NetworkServiceImplTest.java:
##########
@@ -141,11 +146,11 @@ public class NetworkServiceImplTest {
@Mock
VpcManager vpcMgr;
@Mock
- NetworkOrchestrationService networkManager;
+ NetworkOrchestrationService _networkMgr;
@Mock
AlertManager alertManager;
@Mock
- DataCenterDao dcDao;
+ DataCenterDao _dcDao;
Review Comment:
Error message if code change is accepted:
```
[ERROR]
testPerformBasicChecksPromiscuousTypeExpectedCommunitySet(com.cloud.network.NetworkServiceImplTest)
Time elapsed: 0.002 s <<< ERROR!
org.mockito.exceptions.base.MockitoException:
Mockito couldn't inject mock dependency on field
'com.cloud.dc.dao.DataCenterDao com.cloud.network.NetworkServiceImpl._dcDao'
that is annotated with @InjectMocks in your test,
because there were multiple matching mocks (i.e. fields annotated with @Mock
and having matching type): job, networkOfferingServiceMapDao, routerDao,
accountMock, routedIpv4Manager, dataCenterDao, alertManager,
physicalNetworkDao, entityMgr, commandSetupHelper, networkService,
networkOrchestrationService, nicDao, networkHelper, ipv6Service, publicMtuKey,
serviceOfferingVoMock, networkOfferingDao, domainVOMock, _responseObject,
ipAddressDao, userChangeMtuKey, publicIpQuarantineDaoMock, bgpService,
privateMtuKey, userDao, ipAddressManagerMock, vpcMgr, ipMock, vpcDao,
_networkMgr, dcDao, serviceOfferingDaoMock, updateQuarantinedIpCmdMock,
callContextMock, domainDaoMock, publicIpQuarantineVOMock, networkDao,
networkModel, accountVOMock, ipAddressVOMock, nsxProviderDao.
If you have multiple fields of same type in your class under test then
consider naming the @Mock fields identically to the respective class under
test's fields, so Mockito can match them by name.
[ERROR]
testPerformBasicChecksPromiscuousTypeExpectedCommunitySet(com.cloud.network.NetworkServiceImplTest)
Time elapsed: 0.002 s <<< ERROR!
java.lang.NullPointerException: Cannot invoke
"org.mockito.MockedStatic.close()" because "this.callContextMocked" is null
at
com.cloud.network.NetworkServiceImplTest.tearDown(NetworkServiceImplTest.java:334)
```
--
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]