Search in sources :

Example 1 with ControllerProxy

use of com.canoo.platform.remoting.client.ControllerProxy in project dolphin-platform by canoo.

the class ControllerProxyFactory method create.

public <T> CompletableFuture<ControllerProxy<T>> create(String name, String parentControllerId) {
    Assert.requireNonBlank(name, "name");
    final InternalAttributesBean bean = platformBeanRepository.getInternalAttributesBean();
    final CreateControllerCommand createControllerCommand = new CreateControllerCommand();
    createControllerCommand.setControllerName(name);
    if (parentControllerId != null) {
        createControllerCommand.setParentControllerId(parentControllerId);
    }
    return dolphinCommandHandler.invokeDolphinCommand(createControllerCommand).thenApply(new Function<Void, ControllerProxy<T>>() {

        @Override
        public ControllerProxy<T> apply(Void aVoid) {
            return new ControllerProxyImpl<T>(bean.getControllerId(), (T) bean.getModel(), clientConnector, platformBeanRepository, ControllerProxyFactory.this, converters);
        }
    });
}
Also used : InternalAttributesBean(com.canoo.dp.impl.remoting.InternalAttributesBean) ControllerProxy(com.canoo.platform.remoting.client.ControllerProxy) CreateControllerCommand(com.canoo.dp.impl.remoting.commands.CreateControllerCommand)

Example 2 with ControllerProxy

use of com.canoo.platform.remoting.client.ControllerProxy in project dolphin-platform by canoo.

the class ControllerWithoutModelTest method testCreateController.

@Test(dataProvider = ENDPOINTS_DATAPROVIDER, description = "Test if all bean types of Dolphin Platform can be injected in a controller")
public void testCreateController(String containerType, String endpoint) {
    try {
        ClientContext context = connect(endpoint);
        ControllerProxy controller = createController(context, CONTROLLER_WITHOUT_MODEL_NAME);
        Assert.assertNull(controller.getModel());
        destroy(controller, endpoint);
        disconnect(context, endpoint);
    } catch (Exception e) {
        Assert.fail("Error in test for " + containerType, e);
    }
}
Also used : ClientContext(com.canoo.platform.remoting.client.ClientContext) ControllerProxy(com.canoo.platform.remoting.client.ControllerProxy) Test(org.testng.annotations.Test)

Example 3 with ControllerProxy

use of com.canoo.platform.remoting.client.ControllerProxy in project dolphin-platform by canoo.

the class GlobalNotificationsHandler method init.

public CompletableFuture<Void> init() {
    CompletableFuture<ControllerProxy<NotificationWrapperBean>> controllerFuture = clientContext.createController(GLOBAL_NOTIFICATIONS_CONTROLLER);
    return controllerFuture.handle((c, e) -> {
        if (e != null) {
        // TODO
        }
        NotificationWrapperBean model = c.getModel();
        model.notificationProperty().onChanged(event -> {
            NotificationBean bean = model.getNotification();
            if (bean != null) {
                showNotification(new NotificationData(bean.getTitle(), bean.getDescription(), bean.getMessageType()));
            }
        });
        NotificationBean bean = model.getNotification();
        if (bean != null) {
            showNotification(new NotificationData(bean.getTitle(), bean.getDescription(), bean.getMessageType()));
        }
        return null;
    });
}
Also used : NotificationWrapperBean(com.canoo.dp.impl.platform.projector.notifications.NotificationWrapperBean) NotificationBean(com.canoo.dp.impl.platform.projector.notifications.NotificationBean) ControllerProxy(com.canoo.platform.remoting.client.ControllerProxy) NotificationData(com.canoo.dp.impl.platform.projector.notifications.NotificationData)

Example 4 with ControllerProxy

use of com.canoo.platform.remoting.client.ControllerProxy in project dolphin-platform by canoo.

the class ClientTestFactory method createController.

public static <T> ControllerUnderTest<T> createController(final TestClientContext clientContext, final String controllerName) {
    Assert.requireNonNull(clientContext, "clientContext");
    Assert.requireNonBlank(controllerName, "controllerName");
    try {
        final ControllerProxy<T> proxy = (ControllerProxy<T>) clientContext.createController(controllerName).get();
        return new ControllerUnderTestWrapper<>(clientContext, proxy);
    } catch (Exception e) {
        throw new ControllerTestException("Can't create controller proxy", e);
    }
}
Also used : ControllerProxy(com.canoo.platform.remoting.client.ControllerProxy) ControllerTestException(com.canoo.platform.spring.test.ControllerTestException) ControllerTestException(com.canoo.platform.spring.test.ControllerTestException)

Aggregations

ControllerProxy (com.canoo.platform.remoting.client.ControllerProxy)4 NotificationBean (com.canoo.dp.impl.platform.projector.notifications.NotificationBean)1 NotificationData (com.canoo.dp.impl.platform.projector.notifications.NotificationData)1 NotificationWrapperBean (com.canoo.dp.impl.platform.projector.notifications.NotificationWrapperBean)1 InternalAttributesBean (com.canoo.dp.impl.remoting.InternalAttributesBean)1 CreateControllerCommand (com.canoo.dp.impl.remoting.commands.CreateControllerCommand)1 ClientContext (com.canoo.platform.remoting.client.ClientContext)1 ControllerTestException (com.canoo.platform.spring.test.ControllerTestException)1 Test (org.testng.annotations.Test)1