Skip to content

Instantly share code, notes, and snippets.

@edipofederle
Created April 18, 2013 17:26
Show Gist options
  • Select an option

  • Save edipofederle/5414585 to your computer and use it in GitHub Desktop.

Select an option

Save edipofederle/5414585 to your computer and use it in GitHub Desktop.
@Test
public void shouldAddANewMethodInExistClass() throws Exception{
DocumentManager document = givenADocument("addNewMethodToClass", "simples");
ClassOperations classOperations = new ClassOperations(document);
Architecture arch = givenAArchitecture2("addNewMethodToClass");
assertNotNull(arch);
assertEquals(1, arch.getAllClasses().size());
String idClass = arch.getAllClasses().get(0).getId();
assertNotNull("class id should not be null", idClass);
assertTrue("model should contain class id", modelContainId("addNewMethodToClass", idClass));
List<Argument> arguments2 = new ArrayList<Argument>();
arguments2.add(new Argument("name", Types.STRING));
mestrado.arquitetura.parser.method.Method teste = mestrado.arquitetura.parser.method.Method.create()
.withName("teste").withArguments(arguments2)
.withVisibility(VisibilityKind.PUBLIC_LITERAL)
.withReturn(Types.INTEGER)
.build();
List<Argument> arguments3 = new ArrayList<Argument>();
arguments3.add(new Argument("xyz", Types.INTEGER));
mestrado.arquitetura.parser.method.Method xpto = mestrado.arquitetura.parser.method.Method.create()
.withName("xpto").withArguments(arguments3)
.withVisibility(VisibilityKind.PRIVATE_LITERAL)
.withReturn(Types.LONG)
.build();
classOperations.addMethodToClass(idClass, teste);
classOperations.addMethodToClass(idClass, xpto);
assertTrue(modelContainId("addNewMethodToClass", teste.getId()));
assertTrue(modelContainId("addNewMethodToClass", xpto.getId()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment