/** Tests the result of the rest api single subject single config GET when there is a config. */
  @Test
  public void testSingleSubjectSingleConfig() {
    setUpConfigData();
    final WebTarget wt = target();
    final String response =
        wt.path("network/configuration/devices/device1/basic").request().get(String.class);

    final JsonObject result = Json.parse(response).asObject();
    Assert.assertThat(result, notNullValue());

    Assert.assertThat(result.names(), hasSize(2));

    checkBasicAttributes(result);
  }
Esempio n. 2
0
 @Override
 public String validate(FullSpec spec, JsonValue val) {
   if (!CHANGE.equals(spec.getOp())) {
     return VALID;
   }
   if (val.isObject()) {
     JsonObject jo = (JsonObject) val;
     for (String keySpecStr : jo.names()) {
       // member spec validity
       try {
         new TypeIdSpec(keySpecStr);
       } catch (IllegalArgumentException e) {
         return "invalid spec: " + keySpecStr;
       }
     }
   }
   return VALID;
 }
  /** Tests the result of the rest api GET when there is a config. */
  @Test
  public void testConfigs() {
    setUpConfigData();
    final WebTarget wt = target();
    final String response = wt.path("network/configuration").request().get(String.class);

    final JsonObject result = Json.parse(response).asObject();
    Assert.assertThat(result, notNullValue());

    Assert.assertThat(result.names(), hasSize(2));

    JsonValue devices = result.get("devices");
    Assert.assertThat(devices, notNullValue());

    JsonValue device1 = devices.asObject().get("device1");
    Assert.assertThat(device1, notNullValue());

    JsonValue basic = device1.asObject().get("basic");
    Assert.assertThat(basic, notNullValue());

    checkBasicAttributes(basic);
  }