Search in sources :

Example 16 with IBeanDto

use of org.jowidgets.cap.common.api.bean.IBeanDto 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 17 with IBeanDto

use of org.jowidgets.cap.common.api.bean.IBeanDto 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 18 with IBeanDto

use of org.jowidgets.cap.common.api.bean.IBeanDto 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 19 with IBeanDto

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

the class BeanDtoComparatorTest method testBeanDtoComparatorSort.

@Test
public void testBeanDtoComparatorSort() {
    final IBeanDto bean1 = createBeanDto(new Long(1), "2");
    final IBeanDto bean2 = createBeanDto(new Long(2), "12");
    final List<IBeanDto> beans = new ArrayList<IBeanDto>(2);
    beans.add(bean2);
    beans.add(bean1);
    Assert.assertSame(bean2, beans.get(0));
    Assert.assertSame(bean1, beans.get(1));
    Collections.sort(beans, BeanDtoComparator.create(SORT_NUMBER_PROPERTY_ASC));
    Assert.assertSame(bean1, beans.get(0));
    Assert.assertSame(bean2, beans.get(1));
    Collections.sort(beans, BeanDtoComparator.create(SORT_STRING_PROPERTY_ASC));
    Assert.assertSame(bean2, beans.get(0));
    Assert.assertSame(bean1, beans.get(1));
    Collections.sort(beans, BeanDtoComparator.create(SORT_STRING_PROPERTY_DESC));
    Assert.assertSame(bean1, beans.get(0));
    Assert.assertSame(bean2, beans.get(1));
    Collections.sort(beans, BeanDtoComparator.create(SORT_NUMBER_PROPERTY_DESC));
    Assert.assertSame(bean2, beans.get(0));
    Assert.assertSame(bean1, beans.get(1));
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 20 with IBeanDto

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

the class BeanDtoCollectionFilterImpl method filter.

@Override
public ArrayList<IBeanDto> filter(final Collection<? extends IBeanDto> beanDtos, final IFilter filter, final IExecutionCallback executionCallback) {
    final IBeanDtoFilter beanDtoFilter = CapCommonToolkit.beanDtoFilter();
    final ArrayList<IBeanDto> result = new ArrayList<IBeanDto>();
    for (final IBeanDto beanDto : beanDtos) {
        CapServiceToolkit.checkCanceled(executionCallback);
        if (beanDtoFilter.accept(beanDto, filter)) {
            result.add(beanDto);
        }
    }
    return result;
}
Also used : IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) IBeanDtoFilter(org.jowidgets.cap.common.api.filter.IBeanDtoFilter) ArrayList(java.util.ArrayList)

Aggregations

IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)40 LinkedList (java.util.LinkedList)20 ArrayList (java.util.ArrayList)16 List (java.util.List)12 Test (org.junit.Test)12 IBeanKey (org.jowidgets.cap.common.api.bean.IBeanKey)8 IBeanProxy (org.jowidgets.cap.ui.api.bean.IBeanProxy)7 IBeanDtosUpdate (org.jowidgets.cap.common.api.bean.IBeanDtosUpdate)5 IExecutorService (org.jowidgets.cap.common.api.service.IExecutorService)5 BeanDtosInsertionUpdate (org.jowidgets.cap.common.tools.bean.BeanDtosInsertionUpdate)5 SyncResultCallback (org.jowidgets.cap.common.tools.execution.SyncResultCallback)5 IBeanData (org.jowidgets.cap.common.api.bean.IBeanData)4 BeanKey (org.jowidgets.cap.common.tools.bean.BeanKey)4 HashMap (java.util.HashMap)3 ISort (org.jowidgets.cap.common.api.sort.ISort)3 AbstractUiResultCallback (org.jowidgets.cap.ui.tools.execution.AbstractUiResultCallback)3 TableCellBluePrint (org.jowidgets.tools.model.table.TableCellBluePrint)3 ServiceCanceledException (org.jowidgets.cap.common.api.exception.ServiceCanceledException)2 BeanDtosChangeUpdate (org.jowidgets.cap.common.tools.bean.BeanDtosChangeUpdate)2 IBeanSelectionClipboard (org.jowidgets.cap.ui.api.clipboard.IBeanSelectionClipboard)2