|
16 | 16 | */ |
17 | 17 | package spp.protocol.artifact |
18 | 18 |
|
19 | | -import org.junit.jupiter.api.Assertions.assertEquals |
20 | | -import org.junit.jupiter.api.Assertions.assertNotNull |
| 19 | +import org.junit.jupiter.api.Assertions.* |
21 | 20 | import org.junit.jupiter.api.Test |
22 | 21 |
|
23 | 22 | class ArtifactQualifiedNameTest { |
@@ -58,4 +57,40 @@ class ArtifactQualifiedNameTest { |
58 | 57 | assertEquals("com.example.TestClass", clazz!!.identifier) |
59 | 58 | assertEquals(ArtifactType.CLASS, clazz.type) |
60 | 59 | } |
| 60 | + |
| 61 | + @Test |
| 62 | + fun `test is child of`() { |
| 63 | + val clazz = ArtifactQualifiedName("com.example.TestClass", type = ArtifactType.CLASS) |
| 64 | + val method = ArtifactQualifiedName("com.example.TestClass.fun()", type = ArtifactType.METHOD) |
| 65 | + val methodExpression = ArtifactQualifiedName("com.example.TestClass.fun()#22", type = ArtifactType.EXPRESSION) |
| 66 | + |
| 67 | + assertTrue(methodExpression.isChildOf(clazz)) |
| 68 | + assertTrue(methodExpression.isChildOf(method)) |
| 69 | + assertFalse(methodExpression.isChildOf(methodExpression)) |
| 70 | + |
| 71 | + assertTrue(method.isChildOf(clazz)) |
| 72 | + assertFalse(method.isChildOf(method)) |
| 73 | + |
| 74 | + assertFalse(clazz.isChildOf(clazz)) |
| 75 | + assertFalse(clazz.isChildOf(method)) |
| 76 | + assertFalse(method.isChildOf(methodExpression)) |
| 77 | + } |
| 78 | + |
| 79 | + @Test |
| 80 | + fun `test is parent of`() { |
| 81 | + val clazz = ArtifactQualifiedName("com.example.TestClass", type = ArtifactType.CLASS) |
| 82 | + val method = ArtifactQualifiedName("com.example.TestClass.fun()", type = ArtifactType.METHOD) |
| 83 | + val methodExpression = ArtifactQualifiedName("com.example.TestClass.fun()#22", type = ArtifactType.EXPRESSION) |
| 84 | + |
| 85 | + assertTrue(clazz.isParentOf(methodExpression)) |
| 86 | + assertTrue(method.isParentOf(methodExpression)) |
| 87 | + assertFalse(methodExpression.isParentOf(methodExpression)) |
| 88 | + |
| 89 | + assertTrue(clazz.isParentOf(method)) |
| 90 | + assertFalse(method.isParentOf(method)) |
| 91 | + |
| 92 | + assertFalse(clazz.isParentOf(clazz)) |
| 93 | + assertFalse(method.isParentOf(clazz)) |
| 94 | + assertFalse(methodExpression.isParentOf(method)) |
| 95 | + } |
61 | 96 | } |
0 commit comments