Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cucumber goal #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions livingdoc-examples/microservice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,32 @@
<artifactId>livingdoc-annotations</artifactId>
</dependency>
<!-- end::annotation-livingdoc[] -->

<!-- test -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>7.13.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.15.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -82,6 +108,7 @@
<goal>diagram</goal>
<goal>glossary</goal>
<goal>gherkin</goal>
<goal>cucumber</goal>
</goals>
<configuration>
<diagramStartOptions>src/main/livingdoc/diagram-conception.header</diagramStartOptions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
public class BillingService {

@Inject
@Setter
private BillRepository repository;

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ public interface BillRepository {
Optional<Bill> getLastBill();

Optional<Bill> get(YearMonth parse);

void clear();
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public Optional<Bill> getLastBill() {
public Optional<Bill> get(YearMonth month) {
return bills.stream().filter(bill -> Objects.equals(bill.getMonth(), month)).findFirst();
}

@Override
public void clear() {
bills.clear();
}
}
Original file line number Diff line number Diff line change
@@ -1,72 +1,106 @@
/*
* Living Documentation
*
* Copyright (C) 2023 Focus IT
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package ch.ifocusit.telecom.domain;

import ch.ifocusit.livingdoc.annotations.UbiquitousLanguage;
import ch.ifocusit.livingdoc.annotations.RootAggregate;
import ch.ifocusit.telecom.domain.access.Access;
import ch.ifocusit.telecom.domain.common.AbstractDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.YearMonth;
import java.util.HashSet;
import java.util.Set;

/**
* *Monthly* bill.
* [NOTE]
* Generate by the system at contract birth date.
*
* @since 2017-03-01
*/
@RootAggregate
@UbiquitousLanguage(id = 100)
@Data
@EqualsAndHashCode(callSuper = true)
public class Bill extends AbstractDomain {

/**
* Facturation month.
*/
@UbiquitousLanguage(id = 101)
private YearMonth month;

/**
* Contract concerned by the bill.
*/
@UbiquitousLanguage(id = 102)
private Contract contract;

/**
* Bill contents.
*/
@UbiquitousLanguage(id = 103)
private Set<Access> accesses = new HashSet<>();

/**
* Flag that indicate whenever the bill has been sended to the customer.
*/
private boolean customerInformed;

}
/*
* Living Documentation
*
* Copyright (C) 2023 Focus IT
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package ch.ifocusit.telecom.domain;

import ch.ifocusit.livingdoc.annotations.UbiquitousLanguage;
import ch.ifocusit.livingdoc.annotations.RootAggregate;
import ch.ifocusit.telecom.domain.access.Access;
import ch.ifocusit.telecom.domain.access.CallAccess;
import ch.ifocusit.telecom.domain.access.SmsAccess;
import ch.ifocusit.telecom.domain.common.AbstractDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.Duration;
import java.time.YearMonth;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
* *Monthly* bill.
* [NOTE]
* Generate by the system at contract birth date.
*
* @since 2017-03-01
*/
@RootAggregate
@UbiquitousLanguage(id = 100)
@Data
@EqualsAndHashCode(callSuper = true)
public class Bill extends AbstractDomain {

/**
* Facturation month.
*/
@UbiquitousLanguage(id = 101)
private YearMonth month;

/**
* Contract concerned by the bill.
*/
@UbiquitousLanguage(id = 102)
private Contract contract;

/**
* Bill contents.
*/
@UbiquitousLanguage(id = 103)
private Set<Access> accesses = new HashSet<>();

/**
* Flag that indicate whenever the bill has been sended to the customer.
*/
private boolean customerInformed;

public Set<Access> getAccesses() {
return Collections.unmodifiableSet(accesses);
}

public boolean addAccess(final Access access) {
return this.accesses.add(access);
}

public boolean removeAccess(final Access access) {
return this.accesses.remove(access);
}

public BigDecimal getBillAmount() {
return accesses.stream().map(access -> access.getPrice()).reduce(BigDecimal.ZERO, BigDecimal::add);
}

// tag::calculateCallsDuration[]
public Duration getTotalCallsDuration() {
return accesses.stream().filter(CallAccess.class::isInstance).map(CallAccess.class::cast)
.map(callAccess -> callAccess.getDuration()).reduce(Duration.ZERO, Duration::plus);
}
// end::calculateCallsDuration[]

public long getNbCalls() {
return accesses.stream().filter(CallAccess.class::isInstance).count();
}

public long getNbSms() {
return accesses.stream().filter(SmsAccess.class::isInstance).count();
}}
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
/*
* Living Documentation
*
* Copyright (C) 2023 Focus IT
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package ch.ifocusit.telecom.domain;
import ch.ifocusit.livingdoc.annotations.UbiquitousLanguage;
import ch.ifocusit.telecom.domain.common.AbstractDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDate;
import java.time.MonthDay;
/**
* Telecom contract
*/
@UbiquitousLanguage(id = 200)
@Data
@EqualsAndHashCode(callSuper = true)
public class Contract extends AbstractDomain {
/**
* Contract identifier.
* Generate by the system and communicate to client.
*/
@UbiquitousLanguage(id = 201)
private String id;
/**
* Contract customer.
*/
@UbiquitousLanguage(id = 202)
private Customer customer;
/**
* Contract effect date.
*/
@UbiquitousLanguage(id = 203)
private LocalDate effectDate;
/**
* Extract birth day from effect date.
*
* @return the contract birth date
*/
@UbiquitousLanguage(id = 204)
public MonthDay getBirthDay() {
return MonthDay.from(effectDate);
}
}
/*
* Living Documentation
*
* Copyright (C) 2023 Focus IT
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package ch.ifocusit.telecom.domain;

import ch.ifocusit.livingdoc.annotations.UbiquitousLanguage;
import ch.ifocusit.telecom.domain.common.AbstractDomain;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDate;
import java.time.MonthDay;

/**
* Telecom contract
*/
@UbiquitousLanguage(id = 200)
@Data
@EqualsAndHashCode(callSuper = true)
public class Contract extends AbstractDomain {

/**
* Contract identifier.
* Generate by the system and communicate to client.
*/
@UbiquitousLanguage(id = 201)
private String id;

/**
* Contract customer.
*/
@UbiquitousLanguage(id = 202)
private Customer customer;

/**
* Contract effect date.
*/
@UbiquitousLanguage(id = 203)
private LocalDate effectDate;

/**
* Extract birth day from effect date.
*
* @return the contract birth date
*/
@UbiquitousLanguage(id = 204)
public MonthDay getBirthDay() {
return MonthDay.from(effectDate);
}
}
Loading
Loading