1919
2020package org .apache .cloudstack .oauth2 ;
2121
22- import com .cloud .domain .DomainVO ;
23- import com .cloud .domain . dao . DomainDao ;
22+ import com .cloud .domain .Domain ;
23+ import com .cloud .user . DomainService ;
2424import com .cloud .utils .exception .CloudRuntimeException ;
2525import org .apache .cloudstack .api .ApiConstants ;
2626import org .apache .cloudstack .oauth2 .api .command .DeleteOAuthProviderCmd ;
@@ -61,7 +61,7 @@ public class OAuth2AuthManagerImplTest {
6161 OauthProviderDao _oauthProviderDao ;
6262
6363 @ Mock
64- DomainDao _domainDao ;
64+ DomainService _domainService ;
6565
6666 AutoCloseable closeable ;
6767 @ Before
@@ -273,9 +273,9 @@ public void testResolveDomainIdFromDomainUuid() {
273273 Map <String , Object []> params = new HashMap <>();
274274 params .put (ApiConstants .DOMAIN_ID , new String []{"test-uuid-123" });
275275
276- DomainVO domain = Mockito .mock (DomainVO .class );
276+ Domain domain = Mockito .mock (Domain .class );
277277 when (domain .getId ()).thenReturn (10L );
278- when (_domainDao . findByUuid ("test-uuid-123" )).thenReturn (domain );
278+ when (_domainService . getDomain ("test-uuid-123" )).thenReturn (domain );
279279
280280 Long result = _authManager .resolveDomainId (params );
281281 assertEquals (Long .valueOf (10L ), result );
@@ -295,9 +295,9 @@ public void testResolveDomainIdFromDomainPath() {
295295 Map <String , Object []> params = new HashMap <>();
296296 params .put (ApiConstants .DOMAIN , new String []{"ROOT/child" });
297297
298- DomainVO domain = Mockito .mock (DomainVO .class );
298+ Domain domain = Mockito .mock (Domain .class );
299299 when (domain .getId ()).thenReturn (20L );
300- when (_domainDao . findDomainByPath ( "/ROOT/child/" )).thenReturn (domain );
300+ when (_domainService . findDomainByIdOrPath ( null , "/ROOT/child/" )).thenReturn (domain );
301301
302302 Long result = _authManager .resolveDomainId (params );
303303 assertEquals (Long .valueOf (20L ), result );
@@ -308,9 +308,9 @@ public void testResolveDomainIdFromDomainPathWithSlashes() {
308308 Map <String , Object []> params = new HashMap <>();
309309 params .put (ApiConstants .DOMAIN , new String []{"/ROOT/child/" });
310310
311- DomainVO domain = Mockito .mock (DomainVO .class );
311+ Domain domain = Mockito .mock (Domain .class );
312312 when (domain .getId ()).thenReturn (20L );
313- when (_domainDao . findDomainByPath ( "/ROOT/child/" )).thenReturn (domain );
313+ when (_domainService . findDomainByIdOrPath ( null , "/ROOT/child/" )).thenReturn (domain );
314314
315315 Long result = _authManager .resolveDomainId (params );
316316 assertEquals (Long .valueOf (20L ), result );
@@ -321,7 +321,7 @@ public void testResolveDomainIdReturnsNullWhenNotFound() {
321321 Map <String , Object []> params = new HashMap <>();
322322 params .put (ApiConstants .DOMAIN_ID , new String []{"nonexistent-uuid" });
323323
324- when (_domainDao . findByUuid ("nonexistent-uuid" )).thenReturn (null );
324+ when (_domainService . getDomain ("nonexistent-uuid" )).thenReturn (null );
325325
326326 Long result = _authManager .resolveDomainId (params );
327327 assertNull (result );
@@ -340,9 +340,9 @@ public void testResolveDomainIdPrefersUuidOverPath() {
340340 params .put (ApiConstants .DOMAIN_ID , new String []{"test-uuid" });
341341 params .put (ApiConstants .DOMAIN , new String []{"/ROOT/child/" });
342342
343- DomainVO domain = Mockito .mock (DomainVO .class );
343+ Domain domain = Mockito .mock (Domain .class );
344344 when (domain .getId ()).thenReturn (10L );
345- when (_domainDao . findByUuid ("test-uuid" )).thenReturn (domain );
345+ when (_domainService . getDomain ("test-uuid" )).thenReturn (domain );
346346
347347 Long result = _authManager .resolveDomainId (params );
348348 assertEquals (Long .valueOf (10L ), result );
@@ -354,10 +354,10 @@ public void testResolveDomainIdFallsBackToPathWhenUuidNotFound() {
354354 params .put (ApiConstants .DOMAIN_ID , new String []{"bad-uuid" });
355355 params .put (ApiConstants .DOMAIN , new String []{"/ROOT/" });
356356
357- when (_domainDao . findByUuid ("bad-uuid" )).thenReturn (null );
358- DomainVO domain = Mockito .mock (DomainVO .class );
357+ when (_domainService . getDomain ("bad-uuid" )).thenReturn (null );
358+ Domain domain = Mockito .mock (Domain .class );
359359 when (domain .getId ()).thenReturn (1L );
360- when (_domainDao . findDomainByPath ( "/ROOT/" )).thenReturn (domain );
360+ when (_domainService . findDomainByIdOrPath ( null , "/ROOT/" )).thenReturn (domain );
361361
362362 Long result = _authManager .resolveDomainId (params );
363363 assertEquals (Long .valueOf (1L ), result );
0 commit comments