DefaultOrganizationResourcesProvider implements DefaultResourcesProvider { @Override public List<ResourceImpl> getResources(String accountId) throws ServerException, NotFoundException { final Organization organization = organizationManager.getById(accountId); if (organization.getParent() == null) { return asList( new ResourceImpl(TimeoutResourceType.ID, timeout, TimeoutResourceType.UNIT), new ResourceImpl(RamResourceType.ID, ramPerOrganization, RamResourceType.UNIT), new ResourceImpl( WorkspaceResourceType.ID, workspacesPerOrganization, WorkspaceResourceType.UNIT), new ResourceImpl( RuntimeResourceType.ID, runtimesPerOrganization, RuntimeResourceType.UNIT)); } return Collections.emptyList(); } @Inject  DefaultOrganizationResourcesProvider(
      OrganizationManager organizationManager,
      @Named("che.limits.organization.workspaces.ram") String ramPerOrganization,
      @Named("che.limits.organization.workspaces.count") int workspacesPerOrganization,
      @Named("che.limits.organization.workspaces.run.count") int runtimesPerOrganization,
      @Named("che.limits.workspace.idle.timeout") long timeout); @Override String getAccountType(); @Override List<ResourceImpl> getResources(String accountId);  }
@Test public void shouldNotProvideDefaultResourcesForSuborganization() throws Exception { when(organization.getParent()).thenReturn("parentId"); final List<ResourceImpl> defaultResources = organizationResourcesProvider.getResources("organization123"); verify(organizationManager).getById("organization123"); assertTrue(defaultResources.isEmpty()); }
@Test public void shouldProvideDefaultResourcesForRootOrganization() throws Exception { when(organization.getParent()).thenReturn(null); final List<ResourceImpl> defaultResources = organizationResourcesProvider.getResources("organization123"); verify(organizationManager).getById("organization123"); assertEquals(defaultResources.size(), 4); assertTrue( defaultResources.contains( new ResourceImpl(TimeoutResourceType.ID, 10, TimeoutResourceType.UNIT))); assertTrue( defaultResources.contains( new ResourceImpl(RamResourceType.ID, 2048, RamResourceType.UNIT))); assertTrue( defaultResources.contains( new ResourceImpl(WorkspaceResourceType.ID, 10, WorkspaceResourceType.UNIT))); assertTrue( defaultResources.contains( new ResourceImpl(RuntimeResourceType.ID, 5, RuntimeResourceType.UNIT))); }