-
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.
Fix #8 - Migrate Java code to Kotlin
=== Details ==== * Add code coverage :) #7
- Loading branch information
1 parent
cebacd1
commit 5d816d8
Showing
7 changed files
with
209 additions
and
20 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,3 +1,14 @@ | ||
package com.sesame.core.json.domain | ||
|
||
data class AttrDomain (val isPrimitive : Boolean, val value: Any) | ||
import org.apache.commons.lang3.builder.ToStringBuilder | ||
|
||
data class AttrDomain(val isPrimitive: Boolean, val value: Any) { | ||
|
||
override fun toString(): String { | ||
return ToStringBuilder(this) | ||
.append("isPrimitive", isPrimitive) | ||
.append("value", value) | ||
.build() | ||
} | ||
|
||
} |
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
39 changes: 39 additions & 0 deletions
39
src/test/kotlin/com/sesame/core/SesameBeanPostProcessorConfigTest.kt
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,39 @@ | ||
package com.sesame.core | ||
|
||
import io.mockk.MockKAnnotations | ||
import io.mockk.every | ||
import io.mockk.impl.annotations.MockK | ||
import org.junit.Before | ||
import org.junit.Ignore | ||
import org.junit.Test | ||
import org.springframework.beans.factory.support.BeanDefinitionRegistry | ||
import org.springframework.context.ApplicationContext | ||
|
||
//FIXME: Find a way to tests this post processor | ||
class SesameBeanPostProcessorConfigTest { | ||
|
||
private lateinit var sesameBeanPostProcessorConfiguration: SesameBeanPostProcessorConfiguration | ||
|
||
@MockK | ||
private lateinit var applicationContext: ApplicationContext | ||
|
||
@MockK | ||
private lateinit var registry: BeanDefinitionRegistry | ||
|
||
@Before | ||
fun before() { | ||
MockKAnnotations.init(this) | ||
sesameBeanPostProcessorConfiguration = SesameBeanPostProcessorConfiguration(applicationContext) | ||
} | ||
|
||
@Ignore | ||
@Test | ||
fun `should verify load properties using post processor`() { | ||
|
||
every { applicationContext.environment.getProperty(eq("config.file.path.application.context")) } returns "config/path" | ||
sesameBeanPostProcessorConfiguration.postProcessBeanDefinitionRegistry(registry) | ||
|
||
} | ||
|
||
|
||
} |
38 changes: 38 additions & 0 deletions
38
src/test/kotlin/com/sesame/core/SesameCoreConfigurationTest.kt
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,38 @@ | ||
package com.sesame.core | ||
|
||
import io.mockk.MockKAnnotations.init | ||
import io.mockk.impl.annotations.MockK | ||
import org.junit.Assert.assertNotNull | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.springframework.context.ApplicationContext | ||
|
||
class SesameCoreConfigurationTest { | ||
|
||
private val sesameCoreConfig = SesameCoreConfiguration() | ||
|
||
@MockK | ||
private lateinit var applicationContext: ApplicationContext | ||
|
||
@Before | ||
fun before() { | ||
init(this) | ||
} | ||
|
||
@Test | ||
fun `should verify getJsonSerializable`() { | ||
assertNotNull(sesameCoreConfig.getJsonSerializable()) | ||
} | ||
|
||
@Test | ||
fun `should verify getJsonDeserializable`() { | ||
assertNotNull(sesameCoreConfig.getJsonDeserializable()) | ||
} | ||
|
||
@Test | ||
fun `should verify getSesameBeanPostProcessorConfiguration`(){ | ||
assertNotNull(sesameCoreConfig.getSesameBeanPostProcessorConfiguration(applicationContext)) | ||
} | ||
|
||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/test/kotlin/com/sesame/core/json/domain/AttrDomainTest.kt
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,37 @@ | ||
package com.sesame.core.json.domain | ||
|
||
import org.hamcrest.Matchers.containsString | ||
import org.hamcrest.core.AllOf.allOf | ||
import org.junit.Assert.* | ||
import org.junit.Test | ||
|
||
class AttrDomainTest { | ||
|
||
@Test | ||
fun `should verify toString method`() { | ||
|
||
val attrDomain = AttrDomain(false, "value") | ||
|
||
assertThat(attrDomain.toString(), allOf( | ||
containsString("isPrimitive"), | ||
containsString("value") | ||
|
||
)) | ||
|
||
} | ||
|
||
@Test | ||
fun `should verify get method`() { | ||
|
||
val attrDomainString = AttrDomain(false, "value") | ||
val attrDomainInt = AttrDomain(true, 10) | ||
|
||
assertFalse(attrDomainString.isPrimitive) | ||
assertEquals("value", attrDomainString.value) | ||
|
||
assertTrue(attrDomainInt.isPrimitive) | ||
assertEquals(10, attrDomainInt.value) | ||
|
||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/test/kotlin/com/sesame/core/worker/DocumentationFactoryImplTest.kt
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,37 @@ | ||
package com.sesame.core.worker | ||
|
||
import io.mockk.MockKAnnotations | ||
import io.mockk.impl.annotations.MockK | ||
import org.junit.Assert.assertNotNull | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
||
class DocumentationFactoryImplTest { | ||
|
||
@MockK | ||
private lateinit var textDocumentationWorkerImpl: TextDocumentationWorkerImpl | ||
|
||
@MockK | ||
private lateinit var yamlDocumentationWorkerImpl: YamlDocumentationWorkerImpl | ||
|
||
private lateinit var documentationFactoryImpl: DocumentationFactoryImpl | ||
|
||
@Before | ||
fun before() { | ||
MockKAnnotations.init(this) | ||
|
||
documentationFactoryImpl = DocumentationFactoryImpl(textDocumentationWorkerImpl, | ||
yamlDocumentationWorkerImpl) | ||
} | ||
|
||
@Test | ||
fun `should verify getTextDocumentationWorker`() { | ||
assertNotNull(documentationFactoryImpl.getTextDocumentationWorker()) | ||
} | ||
|
||
@Test | ||
fun `should verify getYamlDocumentationWorker`() { | ||
assertNotNull(documentationFactoryImpl.getYamlDocumentationWorker()) | ||
} | ||
|
||
} |