@Test public void testCreateUIInputManyWithShortName() throws Exception { UIInputMany<String> input = factory.createInputMany("foo", 'f', String.class); Assert.assertNotNull(input); Assert.assertTrue(input.hasFacet(HintsFacet.class)); Assert.assertEquals('f', input.getShortName()); }
@Test public void testCreateUIInputMany() throws Exception { UIInputMany<String> input = factory.createInputMany("foo", String.class); Assert.assertNotNull(input); Assert.assertTrue(input.hasFacet(HintsFacet.class)); Assert.assertEquals(InputComponents.DEFAULT_SHORT_NAME, input.getShortName()); }
@Test public void testCreateUIInputManyDefaultValue() throws Exception { UIInputMany<String> input = factory.createInputMany("foo", 'f', String.class); Assert.assertNotNull(input); input.setDefaultValue((Iterable<String>) null); Assert.assertFalse(input.hasDefaultValue()); }
@Override public Result execute(UIExecutionContext context) { Project project = getSelectedProject(context.getUIContext()); final DependencyFacet deps = project.getFacet(DependencyFacet.class); if (arguments.hasValue()) { int count = 0; for (Dependency gav : arguments.getValue()) { Dependency existingDep = deps.getEffectiveManagedDependency(DependencyBuilder.create(gav).setVersion(null)); if (existingDep != null) { if (context .getPrompt() .promptBoolean( String.format( "Dependency [%s:%s] is currently managed. " + "Reference the existing managed dependency [%s:%s:%s]?", gav.getCoordinate().getArtifactId(), gav.getCoordinate().getGroupId(), existingDep.getCoordinate().getGroupId(), existingDep.getCoordinate().getArtifactId(), existingDep.getCoordinate().getVersion()))) { gav = DependencyBuilder.create(existingDep).setScopeType(gav.getScopeType()); } } this.installer.install(project, gav); count++; } return Results.success( "Installed [" + count + "] dependenc" + (count == 1 ? "y" : "ies") + "."); } return Results.fail("No arguments specified."); }
@Override protected UIInputMany<String> createDelegate() { qualifiers.setCompleter( new UICompleter<String>() { @Override public Iterable<String> getCompletionProposals( final UIContext context, final InputComponent<?, String> input, final String value) { final Project project = Projects.getSelectedProject(projectFactory, context); final List<String> options = new ArrayList<>(); for (String type : CDIOperations.DEFAULT_QUALIFIERS) { if (Strings.isNullOrEmpty(value) || type.startsWith(value)) { options.add(type); } } if (project != null) { for (JavaResource resource : cdiOperations.getProjectQualifiers(project)) { try { JavaSource<?> javaSource = resource.getJavaType(); String qualifiedName = javaSource.getQualifiedName(); if (Strings.isNullOrEmpty(value) || qualifiedName.startsWith(value)) { options.add(qualifiedName); } } catch (FileNotFoundException ignored) { } } } return options; } }); return qualifiers; }