<file_sep>package fr.lacombe;

public class ContractId {
    public ContractId(String anyContractId) {
    }
}
<file_sep>package fr.lacombe.Model.Request;

import fr.lacombe.Model.AdvisorId;
import fr.lacombe.Model.MovementDate;
import fr.lacombe.Model.MovementType;
import fr.lacombe.Model.SubscriberId;

public class HistoryRequest {
    private MovementDate movementDate;
    private AdvisorId advisorId;
    private SubscriberId subscriberId;
    private MovementType movementType;

    public HistoryRequest(MovementDate movementDate, AdvisorId advisorId, SubscriberId subscriberId, MovementType movementType) {

        this.movementDate = movementDate;
        this.advisorId = advisorId;
        this.subscriberId = subscriberId;
        this.movementType = movementType;
    }

    public MovementDate getMovementDate() {
        return movementDate;
    }

    public void setMovementDate(MovementDate movementDate) {
        this.movementDate = movementDate;
    }

    public AdvisorId getAdvisorId() {
        return advisorId;
    }

    public void setAdvisorId(AdvisorId advisorId) {
        this.advisorId = advisorId;
    }

    public SubscriberId getSubscriberId() {
        return subscriberId;
    }

    public void setSubscriberId(SubscriberId subscriberId) {
        this.subscriberId = subscriberId;
    }

    public MovementType getMovementType() {
        return movementType;
    }

    public void setMovementType(MovementType movementType) {
        this.movementType = movementType;
    }
}
<file_sep><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>fr.lacombe.subscriber-address-kata</groupId>
    <artifactId>subscriber-address-kata</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>


    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>2.1.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <version>2.1.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-contract-wiremock</artifactId>
            <version>2.1.2.RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.13.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-spring</artifactId>
            <version>1.2.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.9.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-jre8</artifactId>
            <version>2.24.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.1.5.RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot</artifactId>
            <version>2.1.7.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-test</artifactId>
            <version>2.1.3.RELEASE</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.5.7</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.github.tomakehurst</groupId>
            <artifactId>wiremock-jre8</artifactId>
            <version>2.24.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.9.9</version>
        </dependency>

    </dependencies>



</project><file_sep>package fr.lacombe.Utils;

import com.fasterxml.jackson.databind.ObjectMapper;
import fr.lacombe.Model.ContractList;
import fr.lacombe.Model.Country;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.ArrayList;

@Component
public class JsonMapper extends ObjectMapper {


    public ContractList mapJsonToContractList(ResponseEntity<String> contractRepositoryResponse) throws IOException {
        return new ContractList(new ArrayList<>());
    }

    public Country mapJsonToCountry(ResponseEntity<String> addressRepositoryResponse) throws IOException {
        return this.readValue(addressRepositoryResponse.getBody(), Country.class);
    }
}
<file_sep>package fr.lacombe.Model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

import static fr.lacombe.Model.CountryEnum.FRANCE;

public class Country {


    private CountryEnum countryEnum;

    @JsonCreator
    public Country(@JsonProperty("country") CountryEnum countryEnum) {
        this.countryEnum = countryEnum;
    }

    public boolean isFrance() {
        return countryEnum.equals(FRANCE);
    }

}
<file_sep>package fr.lacombe;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(plugin = "pretty", features = "src/test/resources/cucumber")
public class RunCucumberTest extends SpringIntegrationTest{
}
<file_sep>package fr.lacombe.Model.Request;

import fr.lacombe.Model.ContractList;

public class ContractListRequest extends Request{
    private ContractList contractList;

    public ContractListRequest(ContractList contractList) {
        this.contractList = contractList;
    }

    public ContractList getContractList() {
        return contractList;
    }

    public void setContractList(ContractList contractList) {
        this.contractList = contractList;
    }
}
<file_sep>package fr.lacombe.Model;

import java.time.LocalDateTime;

public class MovementDate {


    private LocalDateTime dateTime;

    public MovementDate(LocalDateTime dateTime) {
        this.dateTime = dateTime;
    }

    public LocalDateTime getDateTime() {
        return dateTime;
    }

    public void setDateTime(LocalDateTime dateTime) {
        this.dateTime = dateTime;
    }
}
<file_sep>package fr.lacombe;

import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration
@SpringBootTest(classes = SpringDemoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class SpringIntegrationTest {
}
<file_sep>package fr.lacombe.Model;

import java.io.Serializable;
import java.util.Objects;

public class SubscriberAddress implements Serializable {

    private CountryEnum countryEnum;
    private int postalCode;
    private String streetName;
    private boolean isAddressActive;
    private String city;

    public SubscriberAddress(CountryEnum countryEnum, String city, int postalCode, String streetName, boolean isAddressActive) {
        this.city = city;
        this.countryEnum = countryEnum;
        this.postalCode = postalCode;
        this.streetName = streetName;
        this.isAddressActive = isAddressActive;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SubscriberAddress that = (SubscriberAddress) o;
        return postalCode == that.postalCode &&
                isAddressActive == that.isAddressActive &&
                countryEnum == that.countryEnum &&
                streetName.equals(that.streetName) &&
                city.equals(that.city);
    }

    @Override
    public int hashCode() {
        return Objects.hash(countryEnum, postalCode, streetName, isAddressActive, city);
    }

    public CountryEnum getCountryEnum() {
        return countryEnum;
    }

    public void setCountryEnum(CountryEnum countryEnum) {
        this.countryEnum = countryEnum;
    }

    public int getPostalCode() {
        return postalCode;
    }

    public void setPostalCode(int postalCode) {
        this.postalCode = postalCode;
    }

    public String getStreetName() {
        return streetName;
    }

    public void setStreetName(String streetName) {
        this.streetName = streetName;
    }

    public boolean isAddressActive() {
        return isAddressActive;
    }

    public void setAddressActive(boolean addressActive) {
        isAddressActive = addressActive;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }
}
<file_sep>package fr.lacombe.Model.Request;

public abstract class Request {
}
<file_sep># suscriber-address-kata<file_sep>package fr.lacombe.Utils;

import fr.lacombe.Model.MovementDate;
import org.springframework.stereotype.Service;

@Service
public class TimeProvider implements TimeProviderInterface{
    @Override
    public MovementDate now() {
        return null;
    }
}
<file_sep>package fr.lacombe.Model.Request;

import fr.lacombe.Model.AdvisorId;
import fr.lacombe.Model.EffectiveDate;
import fr.lacombe.Model.SubscriberAddress;
import fr.lacombe.Model.SubscriberId;

import java.io.Serializable;

public class SubscriberModificationRequest extends Request implements Serializable {

    private SubscriberAddress subscriberAddress;
    private SubscriberId subscriberId;
    private EffectiveDate effectiveDate;
    private AdvisorId advisorId;

    public SubscriberModificationRequest(SubscriberAddress subscriberAddress, SubscriberId subscriberId, EffectiveDate effectiveDate, AdvisorId advisorId) {
        this.subscriberAddress = subscriberAddress;
        this.subscriberId = subscriberId;
        this.effectiveDate = effectiveDate;
        this.advisorId = advisorId;
    }

    public SubscriberAddress getSubscriberAddress() {
        return subscriberAddress;
    }

    public void setSubscriberAddress(SubscriberAddress subscriberAddress) {
        this.subscriberAddress = subscriberAddress;
    }

    public EffectiveDate getEffectiveDate() {
        return effectiveDate;
    }

    public void setEffectiveDate(EffectiveDate effectiveDate) {
        this.effectiveDate = effectiveDate;
    }

    public AdvisorId getAdvisorId() {
        return advisorId;
    }

    public void setAdvisorId(AdvisorId advisorId) {
        this.advisorId = advisorId;
    }

    public SubscriberId getSubscriberId() {
        return subscriberId;
    }

    public void setSubscriberId(SubscriberId subscriberId) {
        this.subscriberId = subscriberId;
    }
}
<file_sep>package fr.lacombe.Model;

public enum MovementType {
    SUSBCRIBER_INFO

}
<file_sep>package fr.lacombe.Model;

import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ContractList {

    public List<SubscriberContract> contracts;

    public ContractList(List<SubscriberContract> contracts) {
        this.contracts = contracts;
    }

    public void modifySubscriberAddressOnAllContracts(SubscriberAddress subscriberAddress) {
        for(SubscriberContract subscriberContract : contracts){
            subscriberContract.modifySubscriberAddress(subscriberAddress);
        }
    }

}
