use of com.yahoo.rdl.Validator in project athenz by yahoo.
the class ZMSImpl method loadSchemaValidator.
void loadSchemaValidator() {
schema = ZMSSchema.instance();
validator = new Validator(schema);
}
use of com.yahoo.rdl.Validator in project athenz by yahoo.
the class ProviderSchemaTest method testTenants.
@Test
public void testTenants() {
Schema schema = ProviderSchema.instance();
Validator validator = new Validator(schema);
Tenant t = new Tenant().setService("test-service").setName("test.domain").setState(TenantState.ACTIVE);
Result result = validator.validate(t, "Tenant");
assertTrue(result.valid);
t = new Tenant().setService("test_service").setName("test.domain").setState(TenantState.ACTIVE);
result = validator.validate(t, "Tenant");
assertTrue(result.valid);
t = new Tenant().setService("test@service").setName("test.domain").setState(TenantState.ACTIVE);
result = validator.validate(t, "Tenant");
assertFalse(result.valid);
}
use of com.yahoo.rdl.Validator in project athenz by yahoo.
the class ProviderSchemaTest method testTenantsMethods.
@Test
public void testTenantsMethods() {
Schema schema = ProviderSchema.instance();
Validator validator = new Validator(schema);
List<String> roles = Arrays.asList("test-role");
List<String> rg = Arrays.asList("test-resource-group");
Tenant t = new Tenant().setService("test-service").setName("test.domain").setState(TenantState.ACTIVE).setRoles(roles).setResourceGroups(rg);
Result result = validator.validate(t, "Tenant");
assertTrue(result.valid);
assertEquals(t.getService(), "test-service");
assertEquals(t.getName(), "test.domain");
assertEquals(t.getState(), TenantState.ACTIVE);
assertEquals(t.getRoles(), roles);
assertEquals(t.getResourceGroups(), rg);
assertEquals(t.getState(), TenantState.fromString("ACTIVE"));
Tenant t2 = new Tenant().setService("test-service").setName("test.domain").setState(TenantState.ACTIVE).setRoles(roles).setResourceGroups(rg);
assertTrue(t.equals(t));
t.setResourceGroups(null);
assertFalse(t.equals(t2));
t.setRoles(null);
assertFalse(t.equals(t2));
t.setState(null);
assertFalse(t.equals(t2));
t.setName(null);
assertFalse(t.equals(t2));
t.setService(null);
assertFalse(t.equals(t2));
assertFalse(t.equals(new String()));
}
use of com.yahoo.rdl.Validator in project athenz by yahoo.
the class ProviderSchemaTest method testTenantResourceGroup.
@Test
public void testTenantResourceGroup() {
Schema schema = ProviderSchema.instance();
Validator validator = new Validator(schema);
TenantResourceGroup trg = new TenantResourceGroup().setService("test-service").setName("test.domain").setResourceGroup("test-group");
Result result = validator.validate(trg, "TenantResourceGroup");
assertTrue(result.valid);
trg = new TenantResourceGroup().setService("test@service").setName("test.domain").setResourceGroup("test-group");
result = validator.validate(trg, "TenantResourceGroup");
assertFalse(result.valid);
}
use of com.yahoo.rdl.Validator in project athenz by yahoo.
the class ProviderSchemaTest method testTenantResourceGroupMethods.
@Test
public void testTenantResourceGroupMethods() {
Schema schema = ProviderSchema.instance();
Validator validator = new Validator(schema);
List<String> roles = Arrays.asList("test-role");
TenantResourceGroup trg = new TenantResourceGroup().setService("test-service").setName("test.domain").setResourceGroup("test-group").setRoles(roles);
Result result = validator.validate(trg, "TenantResourceGroup");
assertTrue(result.valid);
assertEquals(trg.getService(), "test-service");
assertEquals(trg.getName(), "test.domain");
assertEquals(trg.getResourceGroup(), "test-group");
assertEquals(trg.getRoles(), roles);
TenantResourceGroup trg2 = new TenantResourceGroup().setService("test-service").setName("test.domain").setResourceGroup("test-group").setRoles(roles);
assertTrue(trg.equals(trg));
trg.setRoles(null);
assertFalse(trg.equals(trg2));
trg.setResourceGroup(null);
assertFalse(trg.equals(trg2));
trg.setName(null);
assertFalse(trg.equals(trg2));
trg.setService(null);
assertFalse(trg.equals(trg2));
assertFalse(trg.equals(new String()));
}