diff --git a/src/main/kotlin/domain/core/CodeAnnotation.kt b/src/main/kotlin/domain/core/CodeAnnotation.kt index 40875a10..1d690227 100644 --- a/src/main/kotlin/domain/core/CodeAnnotation.kt +++ b/src/main/kotlin/domain/core/CodeAnnotation.kt @@ -2,7 +2,10 @@ package domain.core data class AnnotationKeyValue(var Key: String = "", var Value: String = "") {} -open class CodeAnnotation(var Name: String = "", var KeyValues: Array) { +open class CodeAnnotation( + var Name: String = "", + var KeyValues: Array = arrayOf() +) { open fun isComponentOrRepository(): Boolean { return this.Name == "Component" || this.Name == "Repository" } diff --git a/src/main/kotlin/domain/core/CodeFunction.kt b/src/main/kotlin/domain/core/CodeFunction.kt index c681d718..5e98e69f 100644 --- a/src/main/kotlin/domain/core/CodeFunction.kt +++ b/src/main/kotlin/domain/core/CodeFunction.kt @@ -31,4 +31,30 @@ open class CodeFunction( fun isGetterSetter(): Boolean { return this.Name.startsWith("set") || this.Name.startsWith("get") } + + fun buildFullMethodName(node: CodeDataStruct): String { + return node.Package + "." + node.NodeName + "." + this.Name + } + + + fun getAllCallString(): Array { + var calls = arrayOf() + for (codeCall in this.FunctionCalls) { + if (codeCall.NodeName != "") { + calls += codeCall.buildClassFullName() + } + } + + return calls + } + + fun isJUnitTest(): Boolean { + var isTest = false + for (annotation in this.Annotations) { + if (annotation.isIgnoreOrTest()) { + return true + } + } + return false + } } diff --git a/src/test/kotlin/domain/core/CodeFunctionTest.kt b/src/test/kotlin/domain/core/CodeFunctionTest.kt index de587e20..14c55236 100644 --- a/src/test/kotlin/domain/core/CodeFunctionTest.kt +++ b/src/test/kotlin/domain/core/CodeFunctionTest.kt @@ -22,4 +22,35 @@ internal class CodeFunctionTest { assertEquals(CodeFunction(Name = "getFunc").isGetterSetter(), true) assertEquals(CodeFunction(Name = "setFunc").isGetterSetter(), true) } + + @Test + internal fun shouldEnableBuildFullName() { + val dataStruct = CodeDataStruct(Package = "package", NodeName = "nodeName") + + val fullMethodName = CodeFunction(Name = "getFunc").buildFullMethodName(dataStruct) + + assertEquals(fullMethodName, "package.nodeName.getFunc") + } + + @Test + internal fun shouldGetAllCallStrings() { + var calls = arrayOf() + calls += CodeCall(Package = "package", NodeName = "nodeName") + + val allCallString = CodeFunction(Name = "getFunc", FunctionCalls = calls).getAllCallString() + + assertEquals(allCallString.size, 1) + assertEquals(allCallString[0], "package.nodeName") + } + + + @Test + internal fun shouldHandleJunitTest() { + var annotations = arrayOf() + annotations += CodeAnnotation(Name = "Test") + + val isTest = CodeFunction(Name = "getFunc", Annotations = annotations).isJUnitTest() + + assertEquals(isTest, true) + } }