### Question:
MsoTenantUtilsFactory { public MsoTenantUtils getTenantUtils(String cloudSiteId) throws MsoCloudSiteNotFound { CloudSite cloudSite = cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId)); return getTenantUtilsByServerType(cloudSite.getIdentityService().getIdentityServerType()); }  MsoTenantUtils getTenantUtils(String cloudSiteId); MsoTenantUtils getTenantUtilsByServerType(ServerType serverType);  }### Answer:
@Test public void getTenantUtils_shouldThrowException_whenNoCloudSiteFoundForGivenId() { String cloudSiteId = "CloudSiteId"; given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.empty()); MsoCloudSiteNotFound msoCloudSiteNotFound = catchThrowableOfType( () -> msoTenantUtilsFactory.getTenantUtils(cloudSiteId), MsoCloudSiteNotFound.class); assertThat(msoCloudSiteNotFound.getMessage()).contains(cloudSiteId); }
@Test public void getTenantUtils_shouldReturnNull_forInvalidServerType() throws MsoCloudSiteNotFound { String cloudSiteId = "CloudSiteId"; CloudSite cloudSite = mock(CloudSite.class, RETURNS_DEEP_STUBS); given(cloudConfig.getCloudSite(cloudSiteId)).willReturn(Optional.of(cloudSite)); MsoTenantUtils tenantUtils = msoTenantUtilsFactory.getTenantUtils(cloudSiteId); assertThat(tenantUtils).isNull(); }