use of org.glassfish.admin.rest.model.BaseModel in project Payara by payara.
the class CompositeUtilTest method modelGeneration.
@Test
public void modelGeneration() {
BaseModel model = CompositeUtil.instance().getModel(BaseModel.class);
Assert.assertNotNull(model);
}
use of org.glassfish.admin.rest.model.BaseModel in project Payara by payara.
the class CompositeUtilTest method testBeanValidationSupport.
@Test
public void testBeanValidationSupport() {
Locale locale = null;
final CompositeUtil cu = CompositeUtil.instance();
BaseModel model = cu.getModel(BaseModel.class);
// Redundant, but here for emphasis
model.setName(null);
// Must be between 10 and 15, inclusive
model.setSize(16);
// Not null. Validation pulled in from the ConfigBean
model.setConfigRef(null);
Set<ConstraintViolation<BaseModel>> violations = cu.validateRestModel(locale, model);
Assert.assertEquals(3, violations.size());
}
use of org.glassfish.admin.rest.model.BaseModel in project Payara by payara.
the class CompositeUtilTest method readInJson.
@Test
public void readInJson() throws Exception {
Locale locale = null;
JsonParser parser = Json.createParser(new StringReader(JSON));
parser.next();
JsonObject o = parser.getObject();
BaseModel model = CompositeUtil.instance().unmarshallClass(locale, BaseModel.class, o);
Assert.assertEquals(model.getName(), "testModel");
Assert.assertEquals(model.getRelated().size(), 2);
Assert.assertTrue(model.getRelated().get(0).getDescription().startsWith("description "));
}
Aggregations