Search in sources :

Example 6 with BaseModel

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);
}
Also used : BaseModel(org.glassfish.admin.rest.model.BaseModel) Test(org.testng.annotations.Test)

Example 7 with BaseModel

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());
}
Also used : Locale(java.util.Locale) BaseModel(org.glassfish.admin.rest.model.BaseModel) ConstraintViolation(javax.validation.ConstraintViolation) Test(org.testng.annotations.Test)

Example 8 with BaseModel

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 "));
}
Also used : Locale(java.util.Locale) BaseModel(org.glassfish.admin.rest.model.BaseModel) StringReader(java.io.StringReader) JsonObject(javax.json.JsonObject) JsonParser(javax.json.stream.JsonParser) Test(org.testng.annotations.Test)

Aggregations

BaseModel (org.glassfish.admin.rest.model.BaseModel)8 Test (org.testng.annotations.Test)8 Locale (java.util.Locale)4 JsonObject (javax.json.JsonObject)3 StringReader (java.io.StringReader)2 JsonParser (javax.json.stream.JsonParser)2 ReferenceConstraint (com.sun.enterprise.config.serverbeans.customvalidators.ReferenceConstraint)1 Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 JsonArray (javax.json.JsonArray)1 ConstraintViolation (javax.validation.ConstraintViolation)1 ModelExt1 (org.glassfish.admin.rest.model.ModelExt1)1 ModelExt2 (org.glassfish.admin.rest.model.ModelExt2)1 RelatedModel (org.glassfish.admin.rest.model.RelatedModel)1