3232import org .junit .Test ;
3333import org .junit .runner .RunWith ;
3434import org .mockito .Mock ;
35- import org .mockito .Mockito ;
3635import org .mockito .junit .MockitoJUnitRunner ;
3736import org .springframework .test .util .ReflectionTestUtils ;
3837
4342import static org .junit .Assert .assertEquals ;
4443import static org .junit .Assert .assertThrows ;
4544import static org .mockito .ArgumentMatchers .any ;
45+ import static org .mockito .Mockito .doThrow ;
4646import static org .mockito .Mockito .never ;
4747import static org .mockito .Mockito .times ;
4848import static org .mockito .Mockito .verify ;
@@ -121,7 +121,8 @@ public void linkingDomainRefusesGroupClaimedByLiveAccount() {
121121 AccountVO liveAccount = new AccountVO ();
122122 when (accountDaoMock .findByIdIncludingRemoved (liveAccountId )).thenReturn (liveAccount );
123123
124- assertThrows (CloudRuntimeException .class , () -> ldapManager .linkDomainToLdap (buildCmd ("cn=claimed,dc=my,dc=domain,dc=com" )));
124+ LinkDomainToLdapCmd cmd = buildCmd ("cn=claimed,dc=my,dc=domain,dc=com" );
125+ assertThrows (CloudRuntimeException .class , () -> ldapManager .linkDomainToLdap (cmd ));
125126
126127 verify (ldapTrustMapDaoMock , never ()).persist (any ());
127128 }
@@ -146,9 +147,10 @@ public void linkingDomainDoesNotPersistWhenClearingOldMappingFails() {
146147 LdapTrustMapVO oldMapping = new LdapTrustMapVO (DOMAIN_ID , LdapManager .LinkType .GROUP , "cn=old,dc=my,dc=domain,dc=com" , Account .Type .NORMAL , 0 );
147148 ReflectionTestUtils .setField (oldMapping , "id" , OLD_MAPPING_ID );
148149 when (ldapTrustMapDaoMock .findByDomainId (DOMAIN_ID )).thenReturn (oldMapping );
149- Mockito . doThrow (new CloudRuntimeException ("db blip" )).when (ldapTrustMapDaoMock ).expunge (Long .valueOf (OLD_MAPPING_ID ));
150+ doThrow (new CloudRuntimeException ("db blip" )).when (ldapTrustMapDaoMock ).expunge (Long .valueOf (OLD_MAPPING_ID ));
150151
151- assertThrows (CloudRuntimeException .class , () -> ldapManager .linkDomainToLdap (buildCmd ("cn=new,dc=my,dc=domain,dc=com" )));
152+ LinkDomainToLdapCmd cmd = buildCmd ("cn=new,dc=my,dc=domain,dc=com" );
153+ assertThrows (CloudRuntimeException .class , () -> ldapManager .linkDomainToLdap (cmd ));
152154
153155 verify (ldapTrustMapDaoMock , never ()).persist (any ());
154156 }
@@ -167,7 +169,8 @@ public void relinkingDomainRefusesWhenLdapAccountDependsOnOldMapping() {
167169 ReflectionTestUtils .setField (ldapUser , "source" , User .Source .LDAP );
168170 when (userDaoMock .listByAccount (99L )).thenReturn (List .of (ldapUser ));
169171
170- assertThrows (CloudRuntimeException .class , () -> ldapManager .linkDomainToLdap (buildCmd ("cn=new,dc=my,dc=domain,dc=com" )));
172+ LinkDomainToLdapCmd cmd = buildCmd ("cn=new,dc=my,dc=domain,dc=com" );
173+ assertThrows (CloudRuntimeException .class , () -> ldapManager .linkDomainToLdap (cmd ));
171174
172175 verify (ldapTrustMapDaoMock , never ()).expunge (any (Long .class ));
173176 verify (ldapTrustMapDaoMock , never ()).persist (any ());
0 commit comments