CommandDocMapper { public CommandDoc toDto(QavCommand qavCommand) { CommandDoc result = new CommandDoc(); result.setName(qavCommand.name()); result.setDescription(qavCommand.description()); result.setResult(qavCommand.result()); result.setParameters(getParameterDocs(qavCommand.parameters())); return result; }  CommandDoc toDto(QavCommand qavCommand);  }
@Test public void testToDto() { CommandDoc commandDoc = new CommandDocMapper().toDto(qavCommand1); CommandDoc expected = new CommandDoc(); expected.setName("cmd1"); expected.setDescription("desc1"); expected.setResult("result1"); assertThat(commandDoc, notNullValue()); assertThat(commandDoc, is(expected)); }
@Test public void testToDtoWithParameters() { CommandDoc commandDoc = new CommandDocMapper().toDto(qavCommand2); CommandDoc expected = new CommandDoc(); expected.setName("cmd2"); expected.setDescription("desc2"); expected.setResult("result2"); ParameterDoc param1 = new ParameterDoc(); param1.setName("param1"); param1.setDescription("param1 description"); ParameterDoc param2 = new ParameterDoc(); param2.setName("param2"); param2.setDescription("param2 description"); expected.setParameters(Lists.newArrayList(param1, param2)); assertThat(commandDoc, notNullValue()); assertThat(commandDoc, is(expected)); }