StandaloneTaskFormDisplayScreen { @OnOpen public void onOpen() { final String serverTemplate = place.getParameter(StandaloneConstants.SERVER_TEMPLATE_PARAM, null); final String domainId = place.getParameter(StandaloneConstants.DOMAIN_ID_PARAM, null); final String taskId = place.getParameter(StandaloneConstants.TASK_ID_PARAM, null); displayer.setOnCloseCommand(() -> placeManager.closePlace(place)); if (null != taskId) { TaskKey key = new TaskKey(serverTemplate, domainId, Long.decode(taskId)); HumanTaskDisplayerConfig config = new HumanTaskDisplayerConfig(key); humanTaskFormDisplayProvider.setup(config, displayer); } } @Inject  StandaloneTaskFormDisplayScreen(PlaceManager placeManager, EmbeddedFormDisplayer displayer, HumanTaskFormDisplayProvider humanTaskFormDisplayProvider); @WorkbenchPartTitle String getTitle(); @WorkbenchPartView IsWidget getView(); @OnStartup void onStartup(final PlaceRequest place); @OnOpen void onOpen(); static final String SCREEN_ID; }
@Test public void testOnOpen() { PlaceRequest place = new DefaultPlaceRequest(); place.addParameter(StandaloneConstants.SERVER_TEMPLATE_PARAM, SERVER_TEMPLATE_ID); place.addParameter(StandaloneConstants.DOMAIN_ID_PARAM, DOMAIN_ID); place.addParameter(StandaloneConstants.TASK_ID_PARAM, TASK_ID); screen.onStartup(place); screen.onOpen(); ArgumentCaptor<HumanTaskDisplayerConfig> configArgumentCaptor = ArgumentCaptor.forClass(HumanTaskDisplayerConfig.class); verify(humanTaskFormDisplayProvider).setup(configArgumentCaptor.capture(), any()); HumanTaskDisplayerConfig config = configArgumentCaptor.getValue(); Assertions.assertThat(config) .isNotNull(); Assertions.assertThat(config.getKey()) .isNotNull() .hasFieldOrPropertyWithValue("serverTemplateId", SERVER_TEMPLATE_ID) .hasFieldOrPropertyWithValue("deploymentId", DOMAIN_ID) .hasFieldOrPropertyWithValue("taskId", Long.decode(TASK_ID)); ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class); verify(displayer).setOnCloseCommand(commandArgumentCaptor.capture()); Command command = commandArgumentCaptor.getValue(); Assertions.assertThat(command) .isNotNull(); command.execute(); verify(placeManager).closePlace(place); }