Skip to content

Instantly share code, notes, and snippets.

@Configuration
@ComponentScan(
// basePackageClasses = [Recommendation::class],
includeFilters = [ComponentScan.Filter(type = FilterType.ANNOTATION, value = [DomainService::class, Stub::class])])
class DomainConfiguration
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<configuration>
<compilerPlugins>
<plugin>all-open</plugin>
</compilerPlugins>
<pluginOptions>
<option>all-open:annotation=org.craftsrecords.hexarch.DomainService</option>
<option>all-open:annotation=org.craftsrecords.hexarch.Stub</option>
Feature: As a frequent user,
In order not repeat my preferences at each request,
I want to create my profile with my preferences
Scenario: The user is creating his profile with his preferences
Given a user
And he wants to learn
| DDD | hexagonal architecture |
And he only wants to see
| QUICKIE | CONFERENCE |
import org.craftsrecords.talkadvisor.recommendation.api.CreateProfile
import org.craftsrecords.talkadvisor.recommendation.spi.Profiles
class ProfileStepdefs(private val testContext: TestContext,
private val createProfile: CreateProfile,
private val profiles: Profiles) {
@Given("^he already has a profile$")
fun `he already has a profile`() {
val profile = Profile(testContext.userId, createPreferences())
class CustomPicoFactory : PicoFactory() {
init {
addClass(TestContext::class.java)
addClass(TalksAdvisor::class.java)
addClass(HardCodedTalksSearcher::class.java)
addClass(InMemoryRecommendations::class.java)
addClass(ProfileCreator::class.java)
addClass(InMemoryProfiles::class.java)
}
}
cucumber.api.java.ObjectFactory=org.craftsrecords.talkadvisor.CustomPicoFactory
@RunWith(Cucumber::class)
@CucumberOptions(strict = true, plugin = ["pretty", "json:target/cucumber/recommendation.json"], features = ["classpath:features/recommending-talks.feature"])
class RecommendationFunctionalTests
<properties>
<cucumber.version>4.2.3</cucumber.version>
<assertj-core.version>3.11.1</assertj-core.version>
</properties>
...
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>${cucumber.version}</version>
//Talk is related to the topic
assertThat(talk.title).contains("topic")
//All recommended talks are related to the topic
assertThat(recommendation.talks.map { it.title }).allMatch{ it.contains("topic") }
/* Before */
//Check if the talk is related to a topic
if(talk.title.contains("topic")){}
//Check that the recommendation has some talks related to the topic
if((recommendation.talks.map { it.title }.anyMatch{ it.contains("topic") }){}
/*After cleaning the code*/
if(talk.isRelatedTo("topic")){}
if((recommendation.hasTalksRelatedTo("topic")){}