Skip to content

Commit

Permalink
Merge pull request #38 from moosetechnology/test-issue-36
Browse files Browse the repository at this point in the history
add test with enumeration defined in another location that the class …
  • Loading branch information
badetitou authored Jan 12, 2022
2 parents 2ab5e93 + db8552c commit f3a5dbe
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test_src/ad_hoc/AClassThatUseExternalEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package ad_hoc;

public class AClassThatUseExternalEnum {

private ExternalEnum enumeration;

}
5 changes: 5 additions & 0 deletions test_src/ad_hoc/ExternalEnum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ad_hoc;

public enum ExternalEnum {
One, Two, Three
}
21 changes: 21 additions & 0 deletions tests/fr/inria/verveine/extractor/java/VerveineJTest_AdHoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,27 @@ public void testConstructorInvocations() {
assertEquals("Book(\"The Monster Book of Monsters\",\"Hagrid\")", invok.getSignature());
}

@ Test
public void testDeclaredTypeOfExternalEnum() {
parse(new String[] {"test_src/ad_hoc/ExternalEnum.java", "test_src/ad_hoc/AClassThatUseExternalEnum.java"});

org.moosetechnology.model.famixjava.famixjavaentities.Class aClass = detectFamixElement(org.moosetechnology.model.famixjava.famixjavaentities.Class.class, "AClassThatUseExternalEnum");
assertNotNull(aClass);


org.moosetechnology.model.famixjava.famixjavaentities.Enum externalEnum = detectFamixElement(org.moosetechnology.model.famixjava.famixjavaentities.Enum.class, "ExternalEnum");
assertNotNull(externalEnum);
assertEquals("ExternalEnum", externalEnum.getName());

assertEquals(1, aClass.getAttributes().size());
for (TAttribute ta : aClass.getAttributes()) {
Attribute a = (Attribute) ta;
assertEquals(a.getName(), "enumeration");
assertEquals(externalEnum, a.getDeclaredType());
}

}

@ Test
public void testStubConstructor() {
parse(new String[]{"test_src/ad_hoc/DefaultConstructor.java"});
Expand Down

0 comments on commit f3a5dbe

Please sign in to comment.