Search in sources :

Example 1 with BeanKey

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

the class ExecutorAnnotationPostProcessorTest method testChangeName.

@Test
public void testChangeName() {
    final IExecutorService<String> service = ServiceProvider.getService(new ServiceId<IExecutorService<String>>("changeName", IExecutorService.class));
    Assert.assertNotNull(service);
    final SyncResultCallback<List<IBeanDto>> result = new SyncResultCallback<List<IBeanDto>>();
    service.execute(result, Collections.singletonList(new BeanKey(0, 0)), "Hans", null);
    final List<IBeanDto> dtos = result.getResultSynchronious();
    Assert.assertNotNull(dtos);
    Assert.assertEquals(1, dtos.size());
    final IBeanDto dto = dtos.get(0);
    Assert.assertEquals(0, dto.getId());
    Assert.assertEquals("Hans", dto.getValue("name"));
}
Also used : BeanKey(org.jowidgets.cap.common.tools.bean.BeanKey) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) List(java.util.List) IExecutorService(org.jowidgets.cap.common.api.service.IExecutorService) SyncResultCallback(org.jowidgets.cap.common.tools.execution.SyncResultCallback) Test(org.junit.Test)

Example 2 with BeanKey

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

the class ExecutorAnnotationPostProcessorTest method testChangeFirstAndLastNameWithComplexParameter.

@Test
public void testChangeFirstAndLastNameWithComplexParameter() {
    final IExecutorService<Map<String, String>> service = ServiceProvider.getService(new ServiceId<IExecutorService<Map<String, String>>>("changeFirstAndLastNameWithComplexParameter", IExecutorService.class));
    Assert.assertNotNull(service);
    final SyncResultCallback<List<IBeanDto>> result = new SyncResultCallback<List<IBeanDto>>();
    final Map<String, String> parameter = new HashMap<String, String>() {

        private static final long serialVersionUID = 1L;

        private final String lastName = "Hansen";

        {
            put("firstName", "Hans");
            put("age", "36");
        }

        @SuppressWarnings("unused")
        public String getLastName() {
            return lastName;
        }
    };
    service.execute(result, Collections.singletonList(new BeanKey(0, 0)), parameter, null);
    final List<IBeanDto> dtos = result.getResultSynchronious();
    Assert.assertNotNull(dtos);
    Assert.assertEquals(1, dtos.size());
    final IBeanDto dto = dtos.get(0);
    Assert.assertEquals(0, dto.getId());
    Assert.assertEquals("Hans HANSEN", dto.getValue("name"));
}
Also used : HashMap(java.util.HashMap) IExecutorService(org.jowidgets.cap.common.api.service.IExecutorService) BeanKey(org.jowidgets.cap.common.tools.bean.BeanKey) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) List(java.util.List) SyncResultCallback(org.jowidgets.cap.common.tools.execution.SyncResultCallback) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 3 with BeanKey

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

the class BeanTabFolderModelImpl method getParentBeanKeys.

private List<IBeanKey> getParentBeanKeys() {
    if (parent == null) {
        return null;
    }
    final IBeanSelection<Object> beanSelection = parent.getBeanSelection();
    List<IBeanProxy<Object>> selection = beanSelection.getSelection();
    if (EmptyCheck.isEmpty(selection)) {
        return null;
    } else if (linkType == LinkType.SELECTION_FIRST) {
        selection = selection.subList(0, 1);
    }
    final List<IBeanKey> beanKeys = new LinkedList<IBeanKey>();
    for (final IBeanProxy<Object> proxy : selection) {
        if (proxy != null && !proxy.isDummy() && !proxy.isTransient()) {
            beanKeys.add(new BeanKey(proxy.getId(), proxy.getVersion()));
        }
    }
    return beanKeys;
}
Also used : BeanKey(org.jowidgets.cap.common.tools.bean.BeanKey) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) LinkedList(java.util.LinkedList) IBeanProxy(org.jowidgets.cap.ui.api.bean.IBeanProxy)

Example 4 with BeanKey

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

the class ExecutorAnnotationPostProcessorTest method testChangeFirstAndLastName.

@Test
public void testChangeFirstAndLastName() {
    final IExecutorService<String[]> service = ServiceProvider.getService(new ServiceId<IExecutorService<String[]>>("changeFirstAndLastName", IExecutorService.class));
    Assert.assertNotNull(service);
    final SyncResultCallback<List<IBeanDto>> result = new SyncResultCallback<List<IBeanDto>>();
    service.execute(result, Collections.singletonList(new BeanKey(0, 0)), new String[] { "Hans", "Hansen" }, null);
    final List<IBeanDto> dtos = result.getResultSynchronious();
    Assert.assertNotNull(dtos);
    Assert.assertEquals(1, dtos.size());
    final IBeanDto dto = dtos.get(0);
    Assert.assertEquals(0, dto.getId());
    Assert.assertEquals("Hans Hansen", dto.getValue("name"));
}
Also used : BeanKey(org.jowidgets.cap.common.tools.bean.BeanKey) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) List(java.util.List) IExecutorService(org.jowidgets.cap.common.api.service.IExecutorService) SyncResultCallback(org.jowidgets.cap.common.tools.execution.SyncResultCallback) Test(org.junit.Test)

Example 5 with BeanKey

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

the class ExecutorAnnotationPostProcessorTest method testChangeNameList.

@Test
public void testChangeNameList() {
    final IExecutorService<String> service = ServiceProvider.getService(new ServiceId<IExecutorService<String>>("changeNameList", IExecutorService.class));
    Assert.assertNotNull(service);
    final SyncResultCallback<List<IBeanDto>> result = new SyncResultCallback<List<IBeanDto>>();
    service.execute(result, Collections.singletonList(new BeanKey(0, 0)), "Hans", null);
    final List<IBeanDto> dtos = result.getResultSynchronious();
    Assert.assertNotNull(dtos);
    Assert.assertEquals(1, dtos.size());
    final IBeanDto dto = dtos.get(0);
    Assert.assertEquals(0, dto.getId());
    Assert.assertEquals("Hans", dto.getValue("name"));
}
Also used : BeanKey(org.jowidgets.cap.common.tools.bean.BeanKey) IBeanKey(org.jowidgets.cap.common.api.bean.IBeanKey) IBeanDto(org.jowidgets.cap.common.api.bean.IBeanDto) ArrayList(java.util.ArrayList) List(java.util.List) IExecutorService(org.jowidgets.cap.common.api.service.IExecutorService) SyncResultCallback(org.jowidgets.cap.common.tools.execution.SyncResultCallback) Test(org.junit.Test)

Aggregations

IBeanKey (org.jowidgets.cap.common.api.bean.IBeanKey)8 BeanKey (org.jowidgets.cap.common.tools.bean.BeanKey)8 ArrayList (java.util.ArrayList)4 LinkedList (java.util.LinkedList)4 List (java.util.List)4 IBeanDto (org.jowidgets.cap.common.api.bean.IBeanDto)4 IExecutorService (org.jowidgets.cap.common.api.service.IExecutorService)4 SyncResultCallback (org.jowidgets.cap.common.tools.execution.SyncResultCallback)4 Test (org.junit.Test)4 IBeanProxy (org.jowidgets.cap.ui.api.bean.IBeanProxy)3 HashMap (java.util.HashMap)1 Map (java.util.Map)1