Search in sources :

Example 1 with BeanDtosInsertionUpdate

use of org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate in project jo-client-platform by jo-source.

the class BeanTableModelImplTest method testBeanChangeUpdate.

@Test
public void testBeanChangeUpdate() {
    tableModel.getSortModel().setCurrentSorting(Arrays.asList(new ISort() {

        @Override
        public SortOrder getSortOrder() {
            return SortOrder.ASC;
        }

        @Override
        public String getPropertyName() {
            return "key";
        }
    }));
    tableModel.load();
    triggerPageLoading();
    final IUpdatableResultCallback<IBeanDtosUpdate, List<IBeanDto>> updatableCallback = assertUpdatableResultCallback(resultCallback);
    updatableCallback.finished(new ArrayList<IBeanDto>());
    updatableCallback.update(new BeanDtosInsertionUpdate(Arrays.asList((IBeanDto) bean1, (IBeanDto) bean2)));
    updatableCallback.update(new BeanDtosChangeUpdate(Arrays.asList((IBeanDto) bean1a)));
    final int size = tableModel.getSize();
    assertTrue("2 beans should be loaded, but was " + size, size == 2);
    assertTrue("first bean should be changed by update", tableModel.getBean(0).getValue("value").equals(bean1a.getValue("value")));
    assertTrue("second bean should be unchanged by update", tableModel.getBean(1).getValue("value").equals(bean2.getValue("value")));
}
Also used : BeanDtosChangeUpdate(org.jowidgets.cap.common.tools.bean.BeanDtosChangeUpdate) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ISort(org.jowidgets.cap.common.api.sort.ISort) IBeanDtosUpdate(org.jowidgets.cap.common.api.bean.IBeanDtosUpdate) BeanDtosInsertionUpdate(org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate) Test(org.junit.Test)

Example 2 with BeanDtosInsertionUpdate

use of org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate in project jo-client-platform by jo-source.

the class BeanTableModelImplTest method testBeanInsertionUpdate.

@Test
public void testBeanInsertionUpdate() {
    tableModel.load();
    triggerPageLoading();
    final IUpdatableResultCallback<IBeanDtosUpdate, List<IBeanDto>> updatableCallback = assertUpdatableResultCallback(resultCallback);
    updatableCallback.finished(new ArrayList<IBeanDto>());
    updatableCallback.update(new BeanDtosInsertionUpdate(Arrays.asList((IBeanDto) bean1, (IBeanDto) bean2)));
    final int size = tableModel.getSize();
    assertTrue("2 beans should be loaded, but was " + size, size == 2);
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) IBeanDtosUpdate(org.jowidgets.cap.common.api.bean.IBeanDtosUpdate) BeanDtosInsertionUpdate(org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate) Test(org.junit.Test)

Example 3 with BeanDtosInsertionUpdate

use of org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate in project jo-client-platform by jo-source.

the class BeanTableModelImplTest method testClearUpdateClears.

@Test
public void testClearUpdateClears() {
    tableModel.load();
    triggerPageLoading();
    final IUpdatableResultCallback<IBeanDtosUpdate, List<IBeanDto>> updatableCallback = assertUpdatableResultCallback(resultCallback);
    updatableCallback.finished(new ArrayList<IBeanDto>());
    updatableCallback.update(new BeanDtosInsertionUpdate(Arrays.asList((IBeanDto) bean1, (IBeanDto) bean2)));
    updatableCallback.update(new IBeanDtosClearUpdate() {
    });
    final int size = tableModel.getSize();
    assertTrue("table should be clear but " + size + " bean(s) remained", size == 0);
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) IBeanDtosUpdate(org.jowidgets.cap.common.api.bean.IBeanDtosUpdate) IBeanDtosClearUpdate(org.jowidgets.cap.common.api.bean.IBeanDtosClearUpdate) BeanDtosInsertionUpdate(org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate) Test(org.junit.Test)

Example 4 with BeanDtosInsertionUpdate

use of org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate in project jo-client-platform by jo-source.

the class BeanTableModelImplTest method testBeanChangeUpdateWithChangedPositionInSorting.

@Test
public void testBeanChangeUpdateWithChangedPositionInSorting() {
    tableModel.getSortModel().setCurrentSorting(Arrays.asList(new ISort() {

        @Override
        public SortOrder getSortOrder() {
            return SortOrder.DESC;
        }

        @Override
        public String getPropertyName() {
            return "value";
        }
    }));
    tableModel.load();
    triggerPageLoading();
    final IUpdatableResultCallback<IBeanDtosUpdate, List<IBeanDto>> updatableCallback = assertUpdatableResultCallback(resultCallback);
    updatableCallback.finished(new ArrayList<IBeanDto>());
    updatableCallback.update(new BeanDtosInsertionUpdate(Arrays.asList((IBeanDto) bean2, (IBeanDto) bean1)));
    updatableCallback.update(new BeanDtosChangeUpdate(Arrays.asList((IBeanDto) bean1a)));
    assertTrue("2 beans should be loaded, but was " + tableModel.getSize(), tableModel.getSize() == 2);
    assertTrue("the updated bean should be first now", tableModel.getBean(0).getValue("value").equals(bean1a.getValue("value")));
    assertTrue("the previously first bean should now be second", tableModel.getBean(1).getValue("value").equals(bean2.getValue("value")));
}
Also used : BeanDtosChangeUpdate(org.jowidgets.cap.common.tools.bean.BeanDtosChangeUpdate) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ISort(org.jowidgets.cap.common.api.sort.ISort) IBeanDtosUpdate(org.jowidgets.cap.common.api.bean.IBeanDtosUpdate) BeanDtosInsertionUpdate(org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate) Test(org.junit.Test)

Example 5 with BeanDtosInsertionUpdate

use of org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate in project jo-client-platform by jo-source.

the class BeanTableModelImplTest method testBeanDeletionUpdate.

@Test
public void testBeanDeletionUpdate() {
    tableModel.getSortModel().setCurrentSorting(Arrays.asList(new ISort() {

        @Override
        public SortOrder getSortOrder() {
            return SortOrder.ASC;
        }

        @Override
        public String getPropertyName() {
            return "key";
        }
    }));
    tableModel.load();
    triggerPageLoading();
    final IUpdatableResultCallback<IBeanDtosUpdate, List<IBeanDto>> updatableCallback = assertUpdatableResultCallback(resultCallback);
    updatableCallback.finished(new ArrayList<IBeanDto>());
    updatableCallback.update(new BeanDtosInsertionUpdate(Arrays.asList((IBeanDto) bean1, (IBeanDto) bean2)));
    updatableCallback.update(new BeanDtosDeletionUpdate(Arrays.asList(bean1.getId())));
    final int size = tableModel.getSize();
    assertTrue("Only 1 beans should be loaded, but was " + size, size == 1);
    assertTrue("bean2 should be left", tableModel.getBean(0).getValue("value").equals(bean2.getValue("value")));
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) BeanDtosDeletionUpdate(org.jowidgets.cap.common.tools.bean.BeanDtosDeletionUpdate) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ISort(org.jowidgets.cap.common.api.sort.ISort) IBeanDtosUpdate(org.jowidgets.cap.common.api.bean.IBeanDtosUpdate) BeanDtosInsertionUpdate(org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)5 LinkedList (java.util.LinkedList)5 List (java.util.List)5 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)5 IBeanDtosUpdate (org.jowidgets.cap.common.api.bean.IBeanDtosUpdate)5 BeanDtosInsertionUpdate (org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate)5 Test (org.junit.Test)5 ISort (org.jowidgets.cap.common.api.sort.ISort)3 BeanDtosChangeUpdate (org.jowidgets.cap.common.tools.bean.BeanDtosChangeUpdate)2 IBeanDtosClearUpdate (org.jowidgets.cap.common.api.bean.IBeanDtosClearUpdate)1 BeanDtosDeletionUpdate (org.jowidgets.cap.common.tools.bean.BeanDtosDeletionUpdate)1