示例#1
0
 @Test
 public void testCreateRespectsFlagInMap() {
   TestEntity entity2 =
       app.createAndManageChild(
           TestEntity.Spec.newInstance().configure(MutableMap.of("confName", "baz")));
   assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "baz");
 }
  @Test
  public void testRestoresConfigKeys() throws Exception {
    origApp.createAndManageChild(
        EntitySpec.create(TestEntity.class)
            .configure(TestEntity.CONF_NAME, "nameval")
            .configure(TestEntity.CONF_LIST_PLAIN, ImmutableList.of("val1", "val2"))
            .configure(TestEntity.CONF_MAP_PLAIN, ImmutableMap.of("akey", "aval")));

    newApp = rebind();
    final TestEntity newE =
        (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class));

    assertEquals(newE.getConfig(TestEntity.CONF_NAME), "nameval");
    assertEquals(newE.getConfig(TestEntity.CONF_LIST_PLAIN), ImmutableList.of("val1", "val2"));
    assertEquals(newE.getConfig(TestEntity.CONF_MAP_PLAIN), ImmutableMap.of("akey", "aval"));
  }
示例#3
0
 @Test
 public void testCreateRespectsConfigKey() {
   TestEntity entity2 =
       app.createAndManageChild(
           TestEntity.Spec.newInstance().configure(TestEntity.CONF_NAME, "foo"));
   assertEquals(entity2.getConfig(TestEntity.CONF_NAME), "foo");
 }
  @Test
  public void testRestoresSetConfigKey() throws Exception {
    origApp.createAndManageChild(
        EntitySpec.create(TestEntity.class)
            .configure(TestEntity.CONF_SET_THING.subKey(), "val1")
            .configure(TestEntity.CONF_SET_THING.subKey(), "val2"));

    newApp = rebind();
    final TestEntity newE =
        (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class));

    assertEquals(newE.getConfig(TestEntity.CONF_SET_THING), ImmutableSet.of("val1", "val2"));
  }
  @Test // ListConfigKey deprecated, as order no longer guaranteed
  public void testRestoresListConfigKey() throws Exception {
    origApp.createAndManageChild(
        EntitySpec.create(TestEntity.class)
            .configure(TestEntity.CONF_LIST_THING.subKey(), "val1")
            .configure(TestEntity.CONF_LIST_THING.subKey(), "val2"));

    newApp = rebind();
    final TestEntity newE =
        (TestEntity) Iterables.find(newApp.getChildren(), Predicates.instanceOf(TestEntity.class));

    // assertEquals(newE.getConfig(TestEntity.CONF_LIST_THING), ImmutableList.of("val1", "val2"));
    assertEquals(
        ImmutableSet.copyOf(newE.getConfig(TestEntity.CONF_LIST_THING)),
        ImmutableSet.of("val1", "val2"));
  }