Commit 85f022b8 authored by Julien Topçu's avatar Julien Topçu
Browse files

renaming domain features

changing domain object factories strategy
parent e334c9f1
......@@ -31,7 +31,7 @@ Back to the basics, since the aim of a functional test is "testing the business
![Functional Tests in the Hexagonal Architecture](images/hexagon-implementation.png)
In TalkAdvisor, [Cucumber]( is used to define the features and the scenarios of our business logic. As you can see the feature files are located in [the tests packages of the domain]( beside the [step definitions](
Using the [Gherkin language](, we express the scenarios of a feature [profiles.feature](
Using the [Gherkin language](, we express the scenarios of a feature [creating-a-profile.feature](
Feature: As a frequent user,
In order not repeat my preferences at each request,
......@@ -5,5 +5,5 @@ import cucumber.api.junit.Cucumber
import org.junit.runner.RunWith
@CucumberOptions(strict = true, plugin = ["pretty", "json:target/cucumber/recommendation.json"], features = ["classpath:features/recommendations.feature"])
@CucumberOptions(strict = true, plugin = ["pretty", "json:target/cucumber/recommendation.json"], features = ["classpath:features/recommending-talks.feature"])
class RecommendationFunctionalTests
\ No newline at end of file
......@@ -7,6 +7,6 @@ import
fun createPreferences() =
setOf(Topic("DDD"), Topic("Hexagonal Architecture")),
setOf(TalkFormat.CONFERENCE, TalkFormat.QUICKIE))
setOf(TalkFormat.values().random(), TalkFormat.QUICKIE, TalkFormat.IGNITE))
fun createCriteria(): Criteria = createPreferences()
......@@ -6,7 +6,7 @@ import java.time.Duration.ZERO
import java.time.Duration.ofMinutes
internal class DurationExtensionTest {
internal class DurationTest {
fun `should be positive when greater than zero`() {
......@@ -8,6 +8,6 @@ import org.junit.runner.RunWith
strict = true,
plugin = ["pretty", "json:target/cucumber/profile.json"],
features = ["classpath:features/profiles.feature"],
features = ["classpath:features/creating-a-profile.feature"],
glue = ["classpath:org.craftsrecords.talkadvisor.recommendation.stepdefs"])
class ProfileFunctionalTests
\ No newline at end of file
import org.craftsrecords.talkadvisor.recommendation.criteria.Criteria
import java.time.Duration
import java.time.Duration.ofMinutes
import java.util.*
import kotlin.random.Random
......@@ -19,10 +20,14 @@ fun createTalk(): Talk {
return prepareBuilder().apply { duration = ofMinutes(Random.nextLong(2, 120)) }.build()
private fun durationFrom(criteria: Criteria) = criteria.talksFormats.random().durationRange.start
private fun durationFrom(criteria: Criteria) = criteria.talksFormats.random().randomDuration()
private fun prepareBuilder(): Talk.Builder {
return Talk.with {
id = UUID.randomUUID().toString()
title = "title ${Random.nextInt()}"
private fun TalkFormat.randomDuration(): Duration {
return durationRange.start.plusSeconds(Random.nextLong(1, 59))
package org.craftsrecords.talkadvisor.infra.controller
import org.craftsrecords.talkadvisor.infra.configurations.DomainConfiguration
import org.craftsrecords.talkadvisor.recommendation.profile.createProfileFor
import org.craftsrecords.talkadvisor.recommendation.preferences.Preferences
import org.craftsrecords.talkadvisor.recommendation.preferences.Topic
import org.craftsrecords.talkadvisor.recommendation.profile.Profile
import org.craftsrecords.talkadvisor.recommendation.spi.Profiles
import org.hamcrest.Matchers.*
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
......@@ -96,7 +98,7 @@ internal class RecommendationControllerTest {
.attributes(key("constraints").value("formatted in the ISO-8601 standard")))
.description("the format of the talk")
.attributes(key("constraints").value("Possible values: ${TalkFormat.values().contentToString()}"))))
.attributes(key("constraints").value("Possible values: ${values().contentToString()}"))))
private fun MvcResult.extractIdFromLocationHeader(): String {
......@@ -104,7 +106,12 @@ internal class RecommendationControllerTest {
private fun bootstrapProfileFor(userId: String) {
private fun createProfile(userId: String): Profile {
return Profile(id = userId,
preferences = Preferences(setOf(Topic("DDD"), Topic("Hexagonal Architecture")), setOf(CONFERENCE, QUICKIE)))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment