FactoryBaseValidator { protected void validateWorkspace(Factory factory) throws ApiException { final Workspace workspace = factory.getWorkspace(); if (workspace == null) { return; } if (workspace.getType() != null) { if (!workspace.getType().equals("named") && !workspace.getType().equals("temp")) { throw new ConflictException("Attribute workspace.type have only two possible values - named or temp."); } } if (workspace.getLocation() != null) { if (!workspace.getLocation().equals("owner") && !workspace.getLocation().equals("acceptor")) { throw new ConflictException("Attribute workspace.location have only two possible values - owner or acceptor."); } } } FactoryBaseValidator(AccountDao accountDao,
                                UserDao userDao,
                                PreferenceDao preferenceDao);   }
@Test(expectedExceptions = ApiException.class, expectedExceptionsMessageRegExp = "Attribute workspace.type have only two possible values - named or temp.") public void shouldNotValidateIfWorkspaceTypeIsInvalid() throws ApiException { factory = factory.withWorkspace(dto.createDto(Workspace.class) .withType("wrongg")); validator.validateWorkspace(factory); }
@Test(expectedExceptions = ApiException.class, expectedExceptionsMessageRegExp = "Attribute workspace.location have only two possible values - owner or acceptor.") public void shouldNotValidateIfWorkspaceLocationIsInvalid() throws ApiException { factory = factory.withWorkspace(dto.createDto(Workspace.class) .withLocation("wrongg")); validator.validateWorkspace(factory); }