@Test public void testCreateArtifact() throws Exception { prepare(CreateArtifactCommand.class); // failure tests pushToOutput("createArtifact --type ComplexTypeDeclaration --name FooName"); Assert.assertTrue( stream.toString().contains("The artifact you are trying to create is a derived artifact")); pushToOutput("createArtifact --type XmlDocument --name FooName"); Assert.assertTrue( stream.toString().contains("The artifact you are trying to create is a document artifact")); // the initial create needs to return an artifact, its then used to set the context BaseArtifactType extendedArtifact = ArtifactType.ExtendedArtifactType("FooType").newArtifactInstance(); extendedArtifact.setName("FooName"); Mockito.when(clientMock.createArtifact(Mockito.any(BaseArtifactType.class))) .thenReturn(extendedArtifact); // success tests pushToOutput("createArtifact --type FooType --name FooName --description FooDescription"); ArgumentCaptor<BaseArtifactType> artifact = ArgumentCaptor.forClass(BaseArtifactType.class); Mockito.verify(clientMock, Mockito.times(1)).createArtifact(artifact.capture()); Assert.assertEquals("FooName", artifact.getValue().getName()); Assert.assertEquals("FooDescription", artifact.getValue().getDescription()); Assert.assertEquals("FooType", ArtifactType.valueOf(artifact.getValue()).getExtendedType()); // ensure it was set as the current artifact in the context Assert.assertEquals("FooName", getAeshContext().getCurrentArtifact().getName()); }