Example #1
0
  public void testUnbind() throws Exception {
    final MockAbstractBinder binder = new MockAbstractBinder(root, form, handler);

    binder.bind();

    assertNotNull(binder.getBoundField("stringField"));
    assertNotNull(binder.getBoundAction("someAction"));
    assertNotNull(binder.getBoundDataProvider("dataProviderField"));

    binder.unbind();

    assertNull(binder.getBoundField("stringField"));
    assertNull(binder.getBoundAction("someAction"));
    assertNull(binder.getBoundDataProvider("dataProviderField"));
  }
Example #2
0
  public void testDataProvidedListChanged() throws Exception {
    DataProviderMetadata dataMeta =
        (DataProviderMetadata)
            form.getFormMetadata()
                .getDataProviderMetadatas()
                .get(new MethodEntry(form.getMethod("someDataProvider")));

    MockAbstractBinder binder =
        new MockAbstractBinder(root, form, handler) {
          protected void resetSelectedFields(DataProviderMetadata meta) throws Exception {
            put("resetSelectedFields(DataProviderMetadata)", meta);
          }
        };

    binder.bind();
    MockBoundDataProvider bound =
        (MockBoundDataProvider) binder.getBoundDataProvider(dataMeta.getWidgetName());

    final List list = Collections.singletonList("someValue");

    binder.dataProvidedListChanged(dataMeta, list);

    assertSame(list, bound.get("updateList(List)"));

    form.getController().setResetOnDataProviderChange(false);
    binder.clear();
    bound.clear();

    binder.dataProvidedListChanged(dataMeta, list);

    assertSame(list, bound.get("updateList(List)"));
    assertNull(binder.get("resetSelectedFields(DataProviderMetadata)"));
  }
Example #3
0
  public void testDataProvidedIndexesChanged() throws Exception {
    DataProviderMetadata dataMeta =
        (DataProviderMetadata)
            form.getFormMetadata()
                .getDataProviderMetadatas()
                .get(new MethodEntry(form.getMethod("someDataProvider")));

    MockAbstractBinder binder = new MockAbstractBinder(root, form, handler);

    binder.bind();

    MockBoundDataProvider bound =
        (MockBoundDataProvider) binder.getBoundDataProvider(dataMeta.getWidgetName());

    final int[] indexes = new int[] {2, 5, 10};

    binder.dataProvidedIndexesChanged(dataMeta, indexes);

    assertSame(indexes, bound.get("updateIndexes(int[])"));
  }