use of org.easymock.MockControl in project maven-archetype by apache.
the class DefaultArchetypeSelectionQueryerTest method testNoDefaultArchetype.
public void testNoDefaultArchetype() throws PrompterException {
Map<String, List<Archetype>> map = createDefaultArchetypeCatalog();
MockControl control = MockControl.createControl(Prompter.class);
Prompter prompter = (Prompter) control.getMock();
prompter.prompt("");
control.setMatcher(createArgumentMatcher());
control.setReturnValue("1");
queryer.setPrompter(prompter);
control.replay();
Archetype archetype = queryer.selectArchetype(map);
control.verify();
assertEquals("set-groupId", archetype.getGroupId());
assertEquals("set-artifactId", archetype.getArtifactId());
assertEquals("set-version", archetype.getVersion());
}
use of org.easymock.MockControl in project maven-archetype by apache.
the class DefaultArchetypeSelectionQueryerTest method testArchetypeFiltering.
public void testArchetypeFiltering() throws PrompterException {
Map<String, List<Archetype>> map = createDefaultArchetypeCatalog();
MockControl control = MockControl.createControl(Prompter.class);
Prompter prompter = (Prompter) control.getMock();
prompter.prompt("");
control.setMatcher(createArgumentMatcher());
control.setReturnValue("set-artifactId");
prompter.prompt("");
control.setReturnValue("1");
queryer.setPrompter(prompter);
control.replay();
Archetype archetype = queryer.selectArchetype(map);
control.verify();
assertEquals("set-groupId", archetype.getGroupId());
assertEquals("set-artifactId", archetype.getArtifactId());
assertEquals("set-version", archetype.getVersion());
}
use of org.easymock.MockControl in project maven-archetype by apache.
the class DefaultArchetypeSelectionQueryerTest method testDefaultArchetypeInMapOtherSelection.
public void testDefaultArchetypeInMapOtherSelection() throws PrompterException {
Map<String, List<Archetype>> map = createDefaultArchetypeCatalog();
MockControl control = MockControl.createControl(Prompter.class);
Prompter prompter = (Prompter) control.getMock();
prompter.prompt("", "2");
control.setMatcher(createArgumentMatcher());
control.setReturnValue("1");
queryer.setPrompter(prompter);
control.replay();
ArchetypeDefinition defaultDefinition = new ArchetypeDefinition();
defaultDefinition.setGroupId("default-groupId");
defaultDefinition.setArtifactId("default-artifactId");
defaultDefinition.setVersion("default-version");
Archetype archetype = queryer.selectArchetype(map, defaultDefinition);
control.verify();
assertEquals("set-groupId", archetype.getGroupId());
assertEquals("set-artifactId", archetype.getArtifactId());
assertEquals("set-version", archetype.getVersion());
}
use of org.easymock.MockControl in project maven-archetype by apache.
the class DefaultArchetypeSelectorTest method testArchetypeNotInRequestDefaults.
public void testArchetypeNotInRequestDefaults() throws PrompterException, IOException, UnknownGroup, ArchetypeSelectionFailure, UnknownArchetype, ArchetypeNotDefined {
ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
MockControl control = MockControl.createControl(ArchetypeSelectionQueryer.class);
ArchetypeSelectionQueryer queryer = (ArchetypeSelectionQueryer) control.getMock();
queryer.selectArchetype(Collections.<String, List<Archetype>>emptyMap(), createDefaultArchetypeDefinition());
control.setMatcher(createArgumentMatcher());
Archetype archetype = new Archetype();
archetype.setArtifactId("set-artifactId");
archetype.setGroupId("set-groupId");
archetype.setVersion("set-version");
control.setReturnValue(archetype);
control.replay();
selector.setArchetypeSelectionQueryer(queryer);
selector.selectArchetype(request, Boolean.TRUE, "");
control.verify();
assertEquals("set-groupId", request.getArchetypeGroupId());
assertEquals("set-artifactId", request.getArchetypeArtifactId());
assertEquals("set-version", request.getArchetypeVersion());
}
use of org.easymock.MockControl in project maven-archetype by apache.
the class DefaultArchetypeSelectorTest method testArchetypeArtifactIdInRequest.
public void testArchetypeArtifactIdInRequest() throws PrompterException, IOException, UnknownGroup, ArchetypeSelectionFailure, UnknownArchetype, ArchetypeNotDefined {
ArchetypeGenerationRequest request = new ArchetypeGenerationRequest();
request.setArchetypeArtifactId("preset-artifactId");
MockControl control = MockControl.createControl(ArchetypeSelectionQueryer.class);
ArchetypeSelectionQueryer queryer = (ArchetypeSelectionQueryer) control.getMock();
// expect it to not be called
control.replay();
selector.setArchetypeSelectionQueryer(queryer);
selector.selectArchetype(request, Boolean.TRUE, "");
control.verify();
assertEquals(DefaultArchetypeSelector.DEFAULT_ARCHETYPE_GROUPID, request.getArchetypeGroupId());
assertEquals("preset-artifactId", request.getArchetypeArtifactId());
assertEquals(DefaultArchetypeSelector.DEFAULT_ARCHETYPE_VERSION, request.getArchetypeVersion());
}
Aggregations