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);
}
});
}
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);
}
}
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;
});
}
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);
}
}
Aggregations