FactoryBaseValidator { protected void validateCreator(Factory factory) throws ApiException { final Workspace workspace = factory.getWorkspace(); if (workspace != null && "owner".equals(workspace.getLocation())) { String accountId = factory.getCreator() != null ? emptyToNull(factory.getCreator().getAccountId()) : null; if (accountId == null) { throw new ConflictException("Current workspace location requires factory creator accountId to be set."); } } } FactoryBaseValidator(AccountDao accountDao,
                                UserDao userDao,
                                PreferenceDao preferenceDao);   }
@Test(expectedExceptions = ApiException.class, expectedExceptionsMessageRegExp = "Current workspace location requires factory creator accountId to be set.") public void shouldNotValidateIfWorkspaceLocationOwnerButNotAuthor() throws ApiException { factory = factory.withWorkspace(dto.createDto(Workspace.class).withLocation("owner")).withCreator(null); validator.validateCreator(factory); }