-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
nbauma109
committed
May 19, 2023
1 parent
e9dde77
commit 7146f61
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
src/test/java/org/jd/core/v1/model/javasyntax/declaration/MethodDeclarationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package org.jd.core.v1.model.javasyntax.declaration; | ||
|
||
import org.jd.core.v1.model.javasyntax.expression.StringConstantExpression; | ||
import org.jd.core.v1.model.javasyntax.statement.BaseStatement; | ||
import org.jd.core.v1.model.javasyntax.statement.ReturnExpressionStatement; | ||
import org.jd.core.v1.model.javasyntax.type.ObjectType; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.jd.core.v1.service.converter.classfiletojavasyntax.visitor.TestDeclarationVisitor; | ||
|
||
public class MethodDeclarationTest { | ||
|
||
private MethodDeclaration methodDeclaration; | ||
|
||
@Before | ||
public void setUp() { | ||
BaseStatement statements = new ReturnExpressionStatement(new StringConstantExpression("Hello World")); | ||
methodDeclaration = new MethodDeclaration(0, "methodName", ObjectType.TYPE_STRING, "()V", statements); | ||
} | ||
|
||
@Test | ||
public void testGetAnnotationReferences() { | ||
Assert.assertNull(methodDeclaration.getAnnotationReferences()); | ||
} | ||
|
||
@Test | ||
public void testGetFlags() { | ||
Assert.assertEquals(0, methodDeclaration.getFlags()); | ||
} | ||
|
||
@Test | ||
public void testIsStatic() { | ||
Assert.assertFalse(methodDeclaration.isStatic()); | ||
} | ||
|
||
@Test | ||
public void testIsPublic() { | ||
Assert.assertFalse(methodDeclaration.isPublic()); | ||
} | ||
|
||
@Test | ||
public void testIsAbstract() { | ||
Assert.assertFalse(methodDeclaration.isAbstract()); | ||
} | ||
|
||
@Test | ||
public void testGetName() { | ||
Assert.assertEquals("methodName", methodDeclaration.getName()); | ||
} | ||
|
||
@Test | ||
public void testGetTypeParameters() { | ||
Assert.assertNull(methodDeclaration.getTypeParameters()); | ||
} | ||
|
||
@Test | ||
public void testGetReturnedType() { | ||
Assert.assertEquals(ObjectType.TYPE_STRING, methodDeclaration.getReturnedType()); | ||
} | ||
|
||
@Test | ||
public void testGetFormalParameters() { | ||
Assert.assertNull(methodDeclaration.getFormalParameters()); | ||
} | ||
|
||
@Test | ||
public void testGetExceptionTypes() { | ||
Assert.assertNull(methodDeclaration.getExceptionTypes()); | ||
} | ||
|
||
@Test | ||
public void testGetDescriptor() { | ||
Assert.assertEquals("()V", methodDeclaration.getDescriptor()); | ||
} | ||
|
||
@Test | ||
public void testGetStatements() { | ||
Assert.assertNotNull(methodDeclaration.getStatements()); | ||
Assert.assertTrue(methodDeclaration.getStatements().isReturnExpressionStatement()); | ||
methodDeclaration = new MethodDeclaration(methodDeclaration.getFlags(), methodDeclaration.getName(), methodDeclaration.getReturnedType(), methodDeclaration.getDescriptor()); | ||
Assert.assertNull(methodDeclaration.getStatements()); | ||
} | ||
|
||
@Test | ||
public void testGetDefaultAnnotationValue() { | ||
Assert.assertNull(methodDeclaration.getDefaultAnnotationValue()); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
Assert.assertEquals("MethodDeclaration{methodName ()V}", methodDeclaration.toString()); | ||
} | ||
|
||
@Test | ||
public void testAccept() { | ||
TestDeclarationVisitor visitor = new TestDeclarationVisitor(); | ||
methodDeclaration.accept(visitor); | ||
|
||
Assert.assertEquals(1, visitor.getMethodDeclarationCount()); | ||
} | ||
} |