Skip to content

Conflict when using tzatziki-spring-jpa and tzatziki-spring-mongodb in the same project #614

@mfnztdkt

Description

@mfnztdkt

Hello,

When using both tzatziki JPA/MongoDB dependencies inside the same projects, we get the following error:

Exception in thread "main" io.cucumber.core.runner.DuplicateStepDefinitionException: Duplicate step definitions in com.decathlon.tzatziki.steps.SpringMongoSteps.the_repository_contains_nothing(com.decathlon.tzatziki.utils.Guard,java.lang.reflect.Type) and com.decathlon.tzatziki.steps.SpringJPASteps.the_repository_contains_nothing(com.decathlon.tzatziki.utils.Guard,java.lang.reflect.Type)
	at io.cucumber.core.runner.CachingGlue.lambda$prepareGlue$3(CachingGlue.java:313)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1597)
	at io.cucumber.core.runner.CachingGlue.prepareGlue(CachingGlue.java:307)
	at io.cucumber.core.runner.Runner.runPickle(Runner.java:73)
	at io.cucumber.core.runtime.Runtime.lambda$executePickle$6(Runtime.java:107)
	at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$5(CucumberExecutionContext.java:136)
	at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
	at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:136)

A workaround is to remove the Given and Then annotations of the following methods in SpringMongoSteps.
I personally do not use repository/entities terms when using MongoDB, I prefer the notion of document and that change thus does not impact me. I don't know if that reasoning is shared with the majority of developers.

    //@Given(THAT + GUARD + "the " + TYPE + " repository will contain" + INSERTION_MODE + ":$")
    public void the_repository_will_contain(Guard guard, Type repositoryType, InsertionMode insertionMode, Object content) {
        the_repository_will_contain(guard, getRepositoryByType(repositoryType), insertionMode, objects.resolve(content));
    }

    //@Then(THAT + GUARD + "the " + TYPE + " repository (?:still )?contains" + COMPARING_WITH + ":$")
    public void the_repository_contains(Guard guard, Type type, Comparison comparison, Object content) {
        the_repository_contains(guard, getRepositoryByType(type), comparison, objects.resolve(content));
    }

    //@Then(THAT + GUARD + "the " + TYPE + " repository (?:still )?contains nothing$")
    public void the_repository_contains_nothing(Guard guard, Type type) {
        the_repository_contains_nothing(guard, getRepositoryByType(type));
    }

    //@Given(THAT + GUARD + "the " + TYPE + " entities will contain" + INSERTION_MODE + ":$")
    public void the_entities_will_contain(Guard guard, Type type, InsertionMode insertionMode, Object content) {
        the_repository_will_contain(guard, getRepositoryForDocument(type), insertionMode, objects.resolve(content));
    }

    //@Then(THAT + GUARD + "the " + TYPE + " entities (?:still )?contain" + COMPARING_WITH + ":$")
    public void the_entities_contain(Guard guard, Type type, Comparison comparison, Object content) {
        the_repository_contains(guard, getRepositoryForDocument(type), comparison, objects.resolve(content));
    }

    //@Then(THAT + GUARD + "the " + TYPE + " entities (?:still )?contain nothing$")
    public void the_entities_contain_nothing(Guard guard, Type type) {
        the_repository_contains_nothing(guard, getRepositoryForDocument(type));
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions