@@ -509,46 +509,64 @@ public void testFindCorrectResourceLimitForDomain() {
509509 }
510510
511511 @ Test
512- public void testFindCorrectResourceLimitForDomainProjects () {
512+ public void testResourceUnlimitedForDomainProjects () {
513513 DomainVO domain = Mockito .mock (DomainVO .class );
514514 Mockito .when (domain .getId ()).thenReturn (1L );
515+
515516 long result = resourceLimitManager .findCorrectResourceLimitForDomain (domain , Resource .ResourceType .project ,
516517 hostTags .get (0 ));
517518 Assert .assertEquals (Resource .RESOURCE_UNLIMITED , result );
519+ }
520+ @ Test
521+ public void testSpecificLimitForDomainProjects () {
522+ DomainVO domain = Mockito .mock (DomainVO .class );
523+ Mockito .when (domain .getId ()).thenReturn (2L );
524+ Mockito .when (domain .getParent ()).thenReturn (null );
518525
519- Mockito .when (domain .getId ()).thenReturn (2L );
520- Mockito .when (domain .getParent ()).thenReturn (null );
521- ResourceLimitVO limit = new ResourceLimitVO ();
522- limit .setMax (100L );
523- Mockito .when (resourceLimitDao .findByOwnerIdAndTypeAndTag (2L , Resource .ResourceOwnerType .Domain ,
524- Resource .ResourceType .project , hostTags .get (0 ))).thenReturn (limit );
525- result = resourceLimitManager .findCorrectResourceLimitForDomain (domain , Resource .ResourceType .project ,
526- hostTags .get (0 ));
527- Assert .assertEquals (100L , result );
526+ ResourceLimitVO limit = new ResourceLimitVO ();
527+ limit .setMax (100L );
528+ Mockito .when (resourceLimitDao .findByOwnerIdAndTypeAndTag (2L , Resource .ResourceOwnerType .Domain , Resource .ResourceType .project , hostTags .get (0 ))).thenReturn (limit );
528529
530+ long result = resourceLimitManager .findCorrectResourceLimitForDomain (domain , Resource .ResourceType .project , hostTags .get (0 ));
531+ Assert .assertEquals (100L , result );
532+ }
533+
534+ @ Test
535+ public void testParentDomainLimitForDomainProjects () {
536+ DomainVO domain = Mockito .mock (DomainVO .class );
529537 Mockito .when (domain .getId ()).thenReturn (3L );
538+
530539 DomainVO parentDomain = Mockito .mock (DomainVO .class );
531540 Mockito .when (domain .getParent ()).thenReturn (5L );
532541 Mockito .when (domainDao .findById (5L )).thenReturn (parentDomain );
533- limit = new ResourceLimitVO ();
542+
543+ ResourceLimitVO limit = new ResourceLimitVO ();
534544 limit .setMax (200L );
535545 Mockito .when (resourceLimitDao .findByOwnerIdAndTypeAndTag (3L , Resource .ResourceOwnerType .Domain ,
536546 Resource .ResourceType .project , hostTags .get (0 ))).thenReturn (null );
537547 Mockito .when (resourceLimitDao .findByOwnerIdAndTypeAndTag (5L , Resource .ResourceOwnerType .Domain ,
538548 Resource .ResourceType .project , hostTags .get (0 ))).thenReturn (limit );
539- result = resourceLimitManager .findCorrectResourceLimitForDomain (domain , Resource .ResourceType .project ,
549+
550+ long result = resourceLimitManager .findCorrectResourceLimitForDomain (domain , Resource .ResourceType .project ,
540551 hostTags .get (0 ));
541552 Assert .assertEquals (200L , result );
553+ }
542554
543- long defaultDomainProjectsMax = 250L ;
555+ @ Test
556+ public void testDefaultDomainProjectLimit () {
557+ DomainVO domain = Mockito .mock (DomainVO .class );
544558 Mockito .when (domain .getId ()).thenReturn (4L );
545559 Mockito .when (domain .getParent ()).thenReturn (null );
560+
561+ long defaultDomainProjectsMax = 250L ;
546562 Map <String , Long > domainResourceLimitMap = new HashMap <>();
547563 domainResourceLimitMap .put (Resource .ResourceType .project .name (), defaultDomainProjectsMax );
548564 resourceLimitManager .domainResourceLimitMap = domainResourceLimitMap ;
565+
549566 Mockito .when (resourceLimitDao .findByOwnerIdAndTypeAndTag (4L , Resource .ResourceOwnerType .Domain ,
550567 Resource .ResourceType .project , hostTags .get (0 ))).thenReturn (null );
551- result = resourceLimitManager .findCorrectResourceLimitForDomain (domain , Resource .ResourceType .project ,
568+
569+ long result = resourceLimitManager .findCorrectResourceLimitForDomain (domain , Resource .ResourceType .project ,
552570 hostTags .get (0 ));
553571 Assert .assertEquals (defaultDomainProjectsMax , result );
554572 }
0 commit comments