Skip to content

Commit

Permalink
Merge pull request #108 from mkollenstart/main
Browse files Browse the repository at this point in the history
feat: Add TestSequenceDiagram annotation
  • Loading branch information
jimmarino authored Nov 19, 2024
2 parents 91998ef + 474dcfe commit 7246ff0
Show file tree
Hide file tree
Showing 5 changed files with 295 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2023 TNO
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* TNO - initial annotation implementation
*
*
*/

package org.eclipse.dataspacetck.core.api.system;

import org.junit.jupiter.api.Test;

import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.SOURCE;

/**
* Denotes the sequence diagram of a test.
* <p>
* The Mermaid sequence diagram notation should be used to allow automated generation of documentation for tests.
*/
@Inherited
@Retention(SOURCE)
@Target(METHOD)
@Test
public @interface TestSequenceDiagram {
/**
* MermaidJS Sequence diagram string, without "sequenceDiagram".
*/
String value();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.eclipse.dataspacetck.dsp.verification.cn;

import org.eclipse.dataspacetck.core.api.system.MandatoryTest;
import org.eclipse.dataspacetck.core.api.system.TestSequenceDiagram;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;

Expand All @@ -30,6 +31,30 @@ public class ContractNegotiationConsumer01Test extends AbstractContractNegotiati

@MandatoryTest
@DisplayName("CN_C:01-01: Verify contract request, offer received, consumer accepted, provider agreed, consumer verified, provider finalized")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (provider)
participant CUT as Connector Under Test (consumer)
TCK->>CUT: Signal to start negotiation
CUT->>TCK: ContractRequestMessage
TCK-->>CUT: ContractNegotiation
TCK->>CUT: ContractOfferMessage
CUT-->>TCK: 200 OK
CUT->>TCK: ContractNegotiationEventMessage:accepted
TCK-->>CUT: 200 OK
TCK->>CUT: ContractAgreementMessage
CUT-->>TCK: 200 OK
CUT->>TCK: ContractAgreementVerificationMessage
TCK-->>CUT: 200 OK
TCK->>CUT: ContractNegotiationEventMessage:finalized
CUT-->>TCK: 200 OK
""")
public void cn_c_01_01() {
negotiationMock.recordInitializedAction(ConsumerActions::postRequest);
negotiationMock.recordOfferedAction(ConsumerActions::postAccepted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.eclipse.dataspacetck.dsp.verification.cn;

import org.eclipse.dataspacetck.core.api.system.MandatoryTest;
import org.eclipse.dataspacetck.core.api.system.TestSequenceDiagram;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;

Expand All @@ -30,6 +31,19 @@ public class ContractNegotiationProvider01Test extends AbstractContractNegotiati

@MandatoryTest
@DisplayName("CN:01-01: Verify contract request, offer received, consumer terminated")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractOfferMessage
TCK-->>CUT: 200 OK
CUT->>TCK: ContractNegotiationTerminationMessage
TCK-->>CUT: 200 OK
""")
public void cn_01_01() {

negotiationMock.recordContractRequestedAction(ProviderActions::postOffer);
Expand All @@ -47,6 +61,22 @@ public void cn_01_01() {

@MandatoryTest
@DisplayName("CN:01-02: Verify contract request, offer received, consumer counter-offer, provider terminated")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractOfferMessage
TCK-->>CUT: 200 OK
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractNegotiationTerminationMessage
TCK-->>CUT: 200 OK
""")
public void cn_01_02() {

negotiationMock.recordContractRequestedAction(ProviderActions::postOffer);
Expand All @@ -66,6 +96,30 @@ public void cn_01_02() {

@MandatoryTest
@DisplayName("CN:01-03: Verify contract request, offer received, consumer accepted, provider agreement, consumer verified, provider finalized")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractOfferMessage
TCK-->>CUT: 200 OK
TCK->>CUT: ContractNegotiationEventMessage:accepted
CUT-->>TCK: 200 OK
CUT->>TCK: ContractAgreementMessage
TCK-->>CUT: 200 OK
TCK->>CUT: ContractAgreementVerificationMessage
CUT-->>TCK: 200 OK
CUT->>TCK: ContractNegotiationEventMessage:finalized
CUT->>TCK: ContractNegotiationTerminationMessage
TCK-->>CUT: 200 OK
""")
public void cn_01_03() {

negotiationMock.recordContractRequestedAction(ProviderActions::postOffer);
Expand All @@ -89,6 +143,24 @@ public void cn_01_03() {

@MandatoryTest
@DisplayName("CN:01-04: Verify contract request, provider agreement, consumer verified, provider finalized")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractAgreementMessage
TCK-->>CUT: 200 OK
TCK->>CUT: ContractAgreementVerificationMessage
CUT-->>TCK: 200 OK
CUT->>TCK: ContractNegotiationEventMessage:finalized
CUT->>TCK: ContractNegotiationTerminationMessage
TCK-->>CUT: 200 OK
""")
public void cn_01_04() {

negotiationMock.recordContractRequestedAction(ProviderActions::postAgreed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.eclipse.dataspacetck.dsp.verification.cn;

import org.eclipse.dataspacetck.core.api.system.MandatoryTest;
import org.eclipse.dataspacetck.core.api.system.TestSequenceDiagram;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;

Expand All @@ -31,6 +32,16 @@ public class ContractNegotiationProvider02Test extends AbstractContractNegotiati

@MandatoryTest
@DisplayName("CN:02-01: Verify contract request, provider terminated")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractNegotiationTerminationMessage
TCK-->>CUT: 200 OK
""")
public void cn_02_01() {

negotiationMock.recordContractRequestedAction(ProviderActions::postTerminate);
Expand All @@ -46,6 +57,16 @@ public void cn_02_01() {

@MandatoryTest
@DisplayName("CN:02-02: Verify contract request, consumer terminated")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
TCK->>CUT: ContractNegotiationTerminationMessage
CUT-->>TCK: 200 OK
""")
public void cn_02_02() {

negotiationPipeline
Expand All @@ -59,6 +80,19 @@ public void cn_02_02() {

@MandatoryTest
@DisplayName("CN:02-03: Verify contract request, provider agreement, consumer terminated")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractAgreementMessage
TCK-->>CUT: 200 OK
TCK->>CUT: ContractNegotiationTerminationMessage
CUT-->>TCK: 200 OK
""")
public void cn_02_03() {

negotiationMock.recordContractRequestedAction(ProviderActions::postAgreed);
Expand All @@ -76,6 +110,19 @@ public void cn_02_03() {

@MandatoryTest
@DisplayName("CN:02-04: Verify contract request, offer received, consumer terminated")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractOfferMessage
TCK-->>CUT: 200 OK
TCK->>CUT: ContractNegotiationTerminationMessage
CUT-->>TCK: 200 OK
""")
public void cn_02_04() {

negotiationMock.recordContractRequestedAction(ProviderActions::postOffer);
Expand All @@ -93,6 +140,19 @@ public void cn_02_04() {

@MandatoryTest
@DisplayName("CN:02-05: Verify contract request, offer received, provider terminated")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractOfferMessage
TCK-->>CUT: 200 OK
CUT->>TCK: ContractNegotiationTerminationMessage
TCK-->>CUT: 200 OK
""")
public void cn_02_05() {

negotiationMock.recordContractRequestedAction(negotiation -> {
Expand All @@ -114,6 +174,22 @@ public void cn_02_05() {

@MandatoryTest
@DisplayName("CN:02-06: Verify contract request, offer received, consumer accepted, provider terminated")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractOfferMessage
TCK-->>CUT: 200 OK
TCK->>CUT: ContractNegotiationEventMessage:accepted
CUT-->>TCK: 200 OK
CUT->>TCK: ContractNegotiationTerminationMessage
TCK-->>CUT: 200 OK
""")
public void cn_02_06() {

negotiationMock.recordContractRequestedAction(ProviderActions::postOffer);
Expand All @@ -133,6 +209,22 @@ public void cn_02_06() {

@MandatoryTest
@DisplayName("CN:02-07: Verify contract request, provider agreement, consumer verified, provider terminated")
@TestSequenceDiagram("""
participant TCK as Technology Compatibility Kit (consumer)
participant CUT as Connector Under Test (provider)
TCK->>CUT: ContractRequestMessage
CUT-->>TCK: ContractNegotiation
CUT->>TCK: ContractAgreementMessage
TCK-->>CUT: 200 OK
TCK->>CUT: ContractVerificationMessage
CUT-->>TCK: 200 OK
CUT->>TCK: ContractNegotiationTerminationMessage
TCK-->>CUT: 200 OK
""")
public void cn_02_07() {

negotiationMock.recordContractRequestedAction(ProviderActions::postAgreed);
Expand Down
Loading

0 comments on commit 7246ff0

Please sign in to comment.