NewGuidedDecisionTableHandler extends DefaultNewResourceHandler { @Override public void create(final Package pkg, final String baseFileName, final NewResourcePresenter presenter) { this.newResourcePresenter = presenter; if (!options.isUsingWizard()) { createEmptyDecisionTable(pkg.getPackageMainResourcesPath(), baseFileName); } else { createDecisionTableWithWizard(pkg.getPackageMainResourcesPath(), baseFileName); } } NewGuidedDecisionTableHandler(); @Inject  NewGuidedDecisionTableHandler(final PlaceManager placeManager,
                                         final Caller<GuidedDecisionTableEditorService> service,
                                         final GuidedDTableResourceType resourceType,
                                         final GuidedDecisionTableOptions options,
                                         final BusyIndicatorView busyIndicatorView,
                                         final NewGuidedDecisionTableWizardHelper helper); @Override String getDescription(); @Override IsWidget getIcon(); @Override ResourceTypeDefinition getResourceType(); @Override void create(final Package pkg,
                       final String baseFileName,
                       final NewResourcePresenter presenter); @Override int order();  }
@Test public void testCreate_WithWizard() { final String fileName = "fileName"; final Package pkg = mock(Package.class); final Path resourcesPath = PathFactory.newPath("resources", "default: when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath); when(options.isUsingWizard()).thenReturn(true); when(options.getTableFormat()).thenReturn(TableFormat.EXTENDED_ENTRY); when(options.getHitPolicy()).thenReturn(GuidedDecisionTable52.HitPolicy.FIRST_HIT); handler.create(pkg, fileName, newResourcePresenter); verify(wizardBean, times(1)).setContent(pathCaptor.capture(), fileNameCaptor.capture(), eq(TableFormat.EXTENDED_ENTRY), eq(GuidedDecisionTable52.HitPolicy.FIRST_HIT), any(AsyncPackageDataModelOracle.class), any(NewGuidedDecisionTableWizard.GuidedDecisionTableWizardHandler.class)); }
@Test public void testCreate_WithoutWizard() { final String fileName = "fileName"; final Package pkg = mock(Package.class); final Path resourcesPath = PathFactory.newPath("resources", "default: when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath); when(options.isUsingWizard()).thenReturn(false); handler.create(pkg, fileName, newResourcePresenter); verify(busyIndicatorView, times(1)).hideBusyIndicator(); verify(newResourcePresenter, times(1)).complete(); verify(mockNotificationEvent, times(1)).fire(any(NotificationEvent.class)); verify(newResourceSuccessEventMock, times(1)).fire(any(NewResourceSuccessEvent.class)); verify(placeManager, times(1)).goTo(pathCaptor.capture()); assertEquals("default: pathCaptor.getValue().toURI()); verify(service, times(1)).create(eq(resourcesPath), eq(fileName + "." + resourceType.getSuffix()), any(GuidedDecisionTable52.class), any(String.class)); }
@Test public void testResolvedHitPolicy() throws Exception { final Package pkg = mock(Package.class); final Path resourcesPath = PathFactory.newPath("resources", "default: when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath); when(options.isUsingWizard()).thenReturn(false); when(options.getHitPolicy()).thenReturn(GuidedDecisionTable52.HitPolicy.RESOLVED_HIT); handler.create(pkg, "fileName", newResourcePresenter); final ArgumentCaptor<GuidedDecisionTable52> dtableArgumentCaptor = ArgumentCaptor.forClass(GuidedDecisionTable52.class); verify(service, times(1)).create(eq(resourcesPath), eq("fileName." + resourceType.getSuffix()), dtableArgumentCaptor.capture(), any(String.class)); final GuidedDecisionTable52 model = dtableArgumentCaptor.getValue(); assertEquals(1, model.getMetadataCols() .size()); final MetadataCol52 metadataCol52 = model.getMetadataCols().get(0); assertEquals(GuidedDecisionTable52.HitPolicy.RESOLVED_HIT_METADATA_NAME, metadataCol52.getMetadata()); }