Skip to content

Commit 9f45c02

Browse files
Trying to fix tests
1 parent db22972 commit 9f45c02

4 files changed

Lines changed: 32 additions & 38 deletions

File tree

app/src/main/java/fr/inria/verveine/extractor/java/visitors/refvisitors/VisitorInheritanceRef.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import fr.inria.verveine.extractor.java.utils.Util;
77
import fr.inria.verveine.extractor.java.visitors.GetVisitedEntityAbstractVisitor;
88
import org.eclipse.jdt.core.dom.*;
9+
import org.moosetechnology.model.famix.famixjavaentities.Class;
910
import org.moosetechnology.model.famix.famixjavaentities.ContainerEntity;
1011
import org.moosetechnology.model.famix.famixjavaentities.Package;
1112
import org.moosetechnology.model.famix.famixjavaentities.ParametricClass;
@@ -74,16 +75,14 @@ public boolean visit(EnumDeclaration node) {
7475

7576
if ((fmx != null) && (bnd != null)) {
7677
// --------------- implicit superclass java.lang.Enum<> cannot use ensureInheritances(bnd,fmx)
77-
ParametricClass superclass;
78+
TType superclass;
7879
ITypeBinding supbnd = null;
79-
if (bnd != null) {
80-
supbnd = bnd.getSuperclass();
81-
}
80+
supbnd = bnd.getSuperclass();
8281
if (supbnd != null) {
83-
superclass =(ParametricClass) dico.ensureFamixType(supbnd);
82+
superclass = dico.ensureFamixType(supbnd);
8483
} else {
8584
Package javaLang = dico.ensureFamixPackageJavaLang(null);
86-
superclass = (ParametricClass) dico.ensureFamixClass(/*bnd*/null, /*name*/"Enum", /*owner*/javaLang, /*isGeneric*/true, /*modifiers*/Modifier.ABSTRACT & Modifier.PUBLIC);
85+
superclass = dico.ensureFamixClass(/*bnd*/null, /*name*/"Enum", /*owner*/javaLang, /*isGeneric*/true, /*modifiers*/Modifier.ABSTRACT & Modifier.PUBLIC);
8786
}
8887
dico.ensureFamixInheritance((TWithInheritances) superclass, fmx, /*lastInheritance*/null, supbnd);
8988

app/src/main/java/fr/inria/verveine/extractor/java/visitors/refvisitors/VisitorTypeRefRef.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void endVisit(CompilationUnit node) {
6464

6565
@Override
6666
public boolean visit(TypeDeclaration node) {
67-
if (visitTypeDeclaration( node) != null) {
67+
if (visitTypeDeclaration(node) != null) {
6868
return super.visit(node);
6969
} else {
7070
return false;
@@ -317,10 +317,10 @@ public boolean visit(VariableDeclarationStatement node) {
317317
@SuppressWarnings("unchecked")
318318
@Override
319319
public boolean visit(MethodInvocation node) {
320-
Expression receivr = node.getExpression();
321-
if (receivr != null) {
320+
Expression receiver = node.getExpression();
321+
if (receiver != null) {
322322
searchTypeRef = true;
323-
receivr.accept(this);
323+
receiver.accept(this);
324324
searchTypeRef = false;
325325
}
326326
for (Expression arg : (List<Expression>)node.arguments()) {

app/src/main/java/org/moosetechnology/model/famix/famixjavaentities/Attribute.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,26 +210,22 @@ public void setIsFinal(Boolean isFinal) {
210210

211211
@FameProperty(name = "isPackageVisibility", derived = true)
212212
public Boolean getIsPackageVisibility() {
213-
// TODO: this is a derived property, implement this method manually.
214-
throw new UnsupportedOperationException("Not yet implemented!");
213+
return this.visibility.equals("package");
215214
}
216-
215+
217216
@FameProperty(name = "isPrivate", derived = true)
218217
public Boolean getIsPrivate() {
219-
// TODO: this is a derived property, implement this method manually.
220-
throw new UnsupportedOperationException("Not yet implemented!");
218+
return this.visibility.equals("private");
221219
}
222-
220+
223221
@FameProperty(name = "isProtected", derived = true)
224222
public Boolean getIsProtected() {
225-
// TODO: this is a derived property, implement this method manually.
226-
throw new UnsupportedOperationException("Not yet implemented!");
223+
return this.visibility.equals("protected");
227224
}
228-
225+
229226
@FameProperty(name = "isPublic", derived = true)
230227
public Boolean getIsPublic() {
231-
// TODO: this is a derived property, implement this method manually.
232-
throw new UnsupportedOperationException("Not yet implemented!");
228+
return this.visibility.equals("public");
233229
}
234230

235231
@FameProperty(name = "isRoot", derived = true)

app/src/test/java/fr/inria/verveine/extractor/java/VerveineJTest_AdHoc.java

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,31 +130,30 @@ public void testConstructorInvocations() {
130130
assertEquals(3, methOutgoingInvocations.size());
131131

132132
// test invocations' signatures
133-
for (TInvocation tinvok : methOutgoingInvocations) {
134-
Invocation invok = (Invocation) tinvok;
135-
Method invoked = (Method) firstElt(invok.getCandidates());
133+
for (var invocation : methOutgoingInvocations) {
134+
Method invoked = (Method) firstElt(invocation.getCandidates());
136135
assertTrue("Unexpected invoked signature: " + invoked.getSignature(),
137-
invok.getSignature().equals("DefaultConstructor()")
138-
|| invok.getSignature().equals("JFrame(\"My title\")")
139-
|| invok.getSignature().equals("methodWithInstanceScope()"));
136+
invocation.getSignature().equals("DefaultConstructor()")
137+
|| invocation.getSignature().equals("JFrame(\"My title\")")
138+
|| invocation.getSignature().equals("methodWithInstanceScope()"));
140139
}
141140

142141
// test constructors
143-
Collection<Method> defaultContructors = entitiesNamed( Method.class, "DefaultConstructor");
144-
assertEquals(2, defaultContructors.size());
145-
for (Method m : defaultContructors) {
142+
Collection<Method> defaultConstructors = entitiesNamed( Method.class, "DefaultConstructor");
143+
assertEquals(2, defaultConstructors.size());
144+
for (Method m : defaultConstructors) {
146145
int nbParam = m.getParameters().size();
147146
assertTrue( (nbParam == 0) || (nbParam == 1) );
148147
assertEquals(1, m.getIncomingInvocations().size());
149148
assertEquals(1, m.getOutgoingInvocations().size());
150149
}
151150

152-
for (Method m : defaultContructors) {
153-
Invocation invok = (Invocation) firstElt(m.getOutgoingInvocations());
154-
if (m.getParameters().size() == 0) {
155-
assertEquals("this(\"For testing\")", invok.getSignature());
151+
for (Method m : defaultConstructors) {
152+
Invocation invocation = (Invocation) firstElt(m.getOutgoingInvocations());
153+
if (m.getParameters().isEmpty()) {
154+
assertEquals("this(\"For testing\")", invocation.getSignature());
156155
} else {
157-
assertEquals("super(why)", invok.getSignature());
156+
assertEquals("super(why)", invocation.getSignature());
158157
}
159158
}
160159

@@ -165,8 +164,8 @@ public void testConstructorInvocations() {
165164
// get called method in InvokWithFullPath
166165
methOutgoingInvocations = meth.getOutgoingInvocations();
167166
assertEquals(1, methOutgoingInvocations.size());
168-
Invocation invok = (Invocation) firstElt(methOutgoingInvocations);
169-
assertEquals("Book(\"The Monster Book of Monsters\",\"Hagrid\")", invok.getSignature());
167+
Invocation invocation = (Invocation) firstElt(methOutgoingInvocations);
168+
assertEquals("Book(\"The Monster Book of Monsters\",\"Hagrid\")", invocation.getSignature());
170169
}
171170

172171
@ Test
@@ -248,7 +247,7 @@ public void testDictionary() {
248247
}
249248
}
250249
assertNotNull(dico);
251-
assertEquals(8 + 2, dico.getMethods().size()); // 8 methods and 2 method concretisations
250+
assertEquals(8, dico.getMethods().size());
252251
assertEquals(3, dico.getAttributes().size());
253252

254253
for (TAttribute ta : dico.getAttributes()) {

0 commit comments

Comments
 (0)