Skip to content

Commit

Permalink
add tests for getAbbreviation
Browse files Browse the repository at this point in the history
  • Loading branch information
Daoortor committed Aug 14, 2024
1 parent a9148fc commit 22de0c0
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.jetbrains.academy.test.system.core

import org.jetbrains.academy.test.system.core.models.classes.TestClass
import org.jetbrains.academy.test.system.core.testData.abbreviation.*
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.junit.jupiter.params.provider.Arguments

class AbbreviationTests {
companion object {
@JvmStatic
fun testData() = listOf(
Arguments.of(withNullableTestClass),
Arguments.of(withTypeAliasTestClass),
Arguments.of(withGenericTypeAliasTestClass),
Arguments.of(withDoubleTypeAliasTestClass),
Arguments.of(withNullableGenericParametersTestClass)
)
}

@ParameterizedTest
@MethodSource("testData")
fun testAbbreviation(testClass: TestClass) {
val clazz = testClass.checkBaseDefinition()
testClass.checkFieldsDefinition(clazz)
testClass.checkDeclaredMethods(clazz)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jetbrains.academy.test.system.core.testData.abbreviation

import org.jetbrains.academy.test.system.core.models.TestKotlinType
import org.jetbrains.academy.test.system.core.models.Visibility
import org.jetbrains.academy.test.system.core.models.classes.TestClass
import org.jetbrains.academy.test.system.core.models.variable.TestVariable
import org.jetbrains.academy.test.system.core.models.variable.VariableMutability

val identifierMapKotlinType = TestKotlinType(
"Map",
"kotlin.collections.Map<org.jetbrains.academy.test.system.core.testData.abbreviation.Identifier, org.jetbrains.academy.test.system.core.testData.abbreviation.Identifier>"
)

val withDoubleTypeAliasTestClass = TestClass(
"WithDoubleTypeAlias",
"org.jetbrains.academy.test.system.core.testData.abbreviation",
declaredFields = listOf(
TestVariable(
name = "value",
javaType = "Map",
kotlinType = identifierMapKotlinType,
visibility = Visibility.PUBLIC,
mutability = VariableMutability.VAL
)
)
)

typealias Identifier = Int

@Suppress("unused")
data class WithDoubleTypeAlias(val value: Map<Identifier, Identifier>)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jetbrains.academy.test.system.core.testData.abbreviation

import org.jetbrains.academy.test.system.core.models.TestKotlinType
import org.jetbrains.academy.test.system.core.models.Visibility
import org.jetbrains.academy.test.system.core.models.classes.TestClass
import org.jetbrains.academy.test.system.core.models.variable.TestVariable
import org.jetbrains.academy.test.system.core.models.variable.VariableMutability

val dictionaryTestKotlinType = TestKotlinType(
"Map<String, String>",
"org.jetbrains.academy.test.system.core.testData.abbreviation.Dictionary<kotlin.String>"
)

val withGenericTypeAliasTestClass = TestClass(
"WithGenericTypeAlias",
"org.jetbrains.academy.test.system.core.testData.abbreviation",
declaredFields = listOf(
TestVariable(
name = "value",
javaType = "Map",
kotlinType = dictionaryTestKotlinType,
visibility = Visibility.PUBLIC,
mutability = VariableMutability.VAL
)
)
)

typealias Dictionary<T> = Map<String, T>

@Suppress("unused")
data class WithGenericTypeAlias(val value: Dictionary<String>)
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.jetbrains.academy.test.system.core.testData.abbreviation

import org.jetbrains.academy.test.system.core.models.TestKotlinType
import org.jetbrains.academy.test.system.core.models.Visibility
import org.jetbrains.academy.test.system.core.models.classes.TestClass
import org.jetbrains.academy.test.system.core.models.variable.TestVariable
import org.jetbrains.academy.test.system.core.models.variable.VariableMutability

val withNullableTestClass = TestClass(
"WithNullable",
"org.jetbrains.academy.test.system.core.testData.abbreviation",
declaredFields = listOf(
TestVariable(
name = "name",
javaType = "String",
kotlinType = TestKotlinType("String?",
"kotlin.String",
isNullable = true
),
visibility = Visibility.PUBLIC,
mutability = VariableMutability.VAL
)
)
)

@Suppress("unused")
data class WithNullable(val name: String?)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.jetbrains.academy.test.system.core.testData.abbreviation

import org.jetbrains.academy.test.system.core.models.TestKotlinType
import org.jetbrains.academy.test.system.core.models.Visibility
import org.jetbrains.academy.test.system.core.models.classes.TestClass
import org.jetbrains.academy.test.system.core.models.variable.TestVariable
import org.jetbrains.academy.test.system.core.models.variable.VariableMutability

val nullableStringMapKotlinType = TestKotlinType(
"Map",
"kotlin.collections.Map<kotlin.String, kotlin.String>",
)

val withNullableGenericParametersTestClass = TestClass(
"WithNullableGenericParameters",
"org.jetbrains.academy.test.system.core.testData.abbreviation",
declaredFields = listOf(
TestVariable(
name = "value",
javaType = "Map",
kotlinType = nullableStringMapKotlinType,
visibility = Visibility.PUBLIC,
mutability = VariableMutability.VAL
)
)
)

@Suppress("unused")
data class WithNullableGenericParameters(val value: Map<String?, String?>)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jetbrains.academy.test.system.core.testData.abbreviation

import org.jetbrains.academy.test.system.core.models.TestKotlinType
import org.jetbrains.academy.test.system.core.models.Visibility
import org.jetbrains.academy.test.system.core.models.classes.TestClass
import org.jetbrains.academy.test.system.core.models.variable.TestVariable
import org.jetbrains.academy.test.system.core.models.variable.VariableMutability

val typeAliasTestKotlinType = TestKotlinType(
"String",
"org.jetbrains.academy.test.system.core.testData.abbreviation.TypeAlias"
)

val withTypeAliasTestClass = TestClass(
"WithTypeAlias",
"org.jetbrains.academy.test.system.core.testData.abbreviation",
declaredFields = listOf(
TestVariable(
name = "name",
javaType = "String",
kotlinType = typeAliasTestKotlinType,
visibility = Visibility.PUBLIC,
mutability = VariableMutability.VAL
)
)
)

typealias TypeAlias = String

@Suppress("unused")
data class WithTypeAlias(val name: TypeAlias)

0 comments on commit 22de0c0

Please sign in to comment.