-
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 21, 2023
1 parent
f1079ee
commit 1895862
Showing
1 changed file
with
71 additions
and
0 deletions.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
...ore/v1/service/converter/classfiletojavasyntax/visitor/TypeArgumentToTypeVisitorTest.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,71 @@ | ||
package org.jd.core.v1.service.converter.classfiletojavasyntax.visitor; | ||
|
||
import org.jd.core.v1.model.javasyntax.type.DiamondTypeArgument; | ||
import org.jd.core.v1.model.javasyntax.type.GenericType; | ||
import org.jd.core.v1.model.javasyntax.type.ObjectType; | ||
import org.jd.core.v1.model.javasyntax.type.PrimitiveType; | ||
import org.jd.core.v1.model.javasyntax.type.TypeArguments; | ||
import org.jd.core.v1.model.javasyntax.type.WildcardExtendsTypeArgument; | ||
import org.jd.core.v1.model.javasyntax.type.WildcardSuperTypeArgument; | ||
import org.jd.core.v1.model.javasyntax.type.WildcardTypeArgument; | ||
import org.jd.core.v1.service.converter.classfiletojavasyntax.util.TypeMaker; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TypeArgumentToTypeVisitorTest { | ||
|
||
@Test | ||
public void testTypeArgumentToTypeVisitor() { | ||
// Arrange | ||
TypeArgumentToTypeVisitor visitor = new TypeArgumentToTypeVisitor(); | ||
visitor.init(); | ||
|
||
// Act & Assert - PrimitiveType | ||
PrimitiveType primitiveType = PrimitiveType.TYPE_INT; | ||
primitiveType.accept(visitor); | ||
assertEquals(primitiveType, visitor.getType()); | ||
|
||
// Act & Assert - ObjectType | ||
ObjectType objectType = ObjectType.TYPE_STRING; | ||
objectType.accept(visitor); | ||
assertEquals(objectType, visitor.getType()); | ||
|
||
// Act & Assert - InnerObjectType | ||
ObjectType innerObjectType = new TypeMaker().makeFromInternalTypeName("java/util/Map$Entry"); | ||
innerObjectType.accept(visitor); | ||
assertEquals(innerObjectType, visitor.getType()); | ||
|
||
// Act & Assert - GenericType | ||
GenericType genericType = new GenericType("T"); | ||
genericType.accept(visitor); | ||
assertEquals(genericType, visitor.getType()); | ||
|
||
// Act & Assert - WildcardExtendsTypeArgument | ||
WildcardExtendsTypeArgument wildcardExtendsTypeArgument = new WildcardExtendsTypeArgument(ObjectType.TYPE_OBJECT); | ||
wildcardExtendsTypeArgument.accept(visitor); | ||
assertEquals(ObjectType.TYPE_OBJECT, visitor.getType()); | ||
|
||
// Act & Assert - WildcardSuperTypeArgument | ||
WildcardSuperTypeArgument wildcardSuperTypeArgument = new WildcardSuperTypeArgument(ObjectType.TYPE_OBJECT); | ||
wildcardSuperTypeArgument.accept(visitor); | ||
assertEquals(ObjectType.TYPE_OBJECT, visitor.getType()); | ||
|
||
// Act & Assert - DiamondTypeArgument | ||
DiamondTypeArgument diamondTypeArgument = DiamondTypeArgument.DIAMOND; | ||
diamondTypeArgument.accept(visitor); | ||
assertEquals(ObjectType.TYPE_OBJECT, visitor.getType()); | ||
|
||
// Act & Assert - WildcardTypeArgument | ||
WildcardTypeArgument wildcardTypeArgument = WildcardTypeArgument.WILDCARD_TYPE_ARGUMENT; | ||
wildcardTypeArgument.accept(visitor); | ||
assertEquals(ObjectType.TYPE_OBJECT, visitor.getType()); | ||
|
||
// Act & Assert - TypeArguments | ||
TypeArguments typeArguments = new TypeArguments(Arrays.asList(ObjectType.TYPE_OBJECT)); | ||
typeArguments.accept(visitor); | ||
assertEquals(ObjectType.TYPE_UNDEFINED_OBJECT, visitor.getType()); | ||
} | ||
} |