Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/**
* This enumeration represents the different statuses of an item.
*/
// [impl->dsn~specification-item~4]
public enum ItemStatus
{
/**
Expand All @@ -22,7 +23,11 @@ public enum ItemStatus
/**
* The item is rejected.
*/
REJECTED;
REJECTED,
/**
* The item declares an unknown status.
*/
UNKNOWN;

/**
* Parses the given text and return the matching {@link ItemStatus}.
Expand All @@ -34,16 +39,33 @@ public enum ItemStatus
* in case no matching {@link ItemStatus} is found.
*/
public static ItemStatus parseString(final String text)
{
final ItemStatus status = parseOrUnknown(text);
if (status != UNKNOWN)
{
return status;
}
throw new IllegalArgumentException(
"Unrecognized specification item status: \"" + text + "\"");
}

/**
* Parses the given text and returns the matching {@link ItemStatus} or {@link #UNKNOWN}.
*
* @param text
* the text to parse, e.g. {@code "APPROVED"}.
* @return the matching {@link ItemStatus}, or {@link #UNKNOWN} when no known status matches
*/
public static ItemStatus parseOrUnknown(final String text)
{
for (final ItemStatus value : values())
{
if (text.equalsIgnoreCase(value.toString()))
if (value != UNKNOWN && text.equalsIgnoreCase(value.toString()))
{
return value;
}
}
throw new IllegalArgumentException(
"Unrecognized specification item status: \"" + text + "\"");
return UNKNOWN;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* A specification item that requires coverage from other items and provides
* coverage for other items.
*/
// [impl->dsn~specification-item~3]
// [impl->dsn~specification-item~4]
public final class SpecificationItem
{
private final LocatedSpecificationItemId id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class TestSpecificationItem
private static final SpecificationItemId COVERED_ID = SpecificationItemId.parseId("feat~covered~2");
private static final SpecificationItemId DEPEND_ON_ID = SpecificationItemId.parseId("req~dependency~3");

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testBuilderAcceptsLocatedIds()
{
Expand All @@ -30,7 +30,7 @@ void testBuilderAcceptsLocatedIds()
() -> assertThat(item.getDependOnIds(), contains(DEPEND_ON_ID)));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testPreservesCompatibilityForUnlocatedIds()
{
Expand All @@ -43,7 +43,7 @@ void testPreservesCompatibilityForUnlocatedIds()
() -> assertThat(item.getDependOnIds(), contains(DEPEND_ON_ID)));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testToBuilderPreservesAllValues()
{
Expand All @@ -56,7 +56,7 @@ void testToBuilderPreservesAllValues()
assertThat(item.toBuilder().build(), equalTo(item));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testToBuilderDoesNotModifyOriginalItem()
{
Expand All @@ -70,7 +70,7 @@ void testToBuilderDoesNotModifyOriginalItem()
() -> assertThat(copy.getCoveredIds(), contains(COVERED_ID, DEPEND_ON_ID)));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testBuilderReplacesCoveredIds()
{
Expand All @@ -80,7 +80,7 @@ void testBuilderReplacesCoveredIds()
assertThat(item.getCoveredIds(), contains(COVERED_ID));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testBuilderReplacesDependencyIds()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class TestItemStatus
{

// [utest->dsn~specification-item~4]
@Test
void testParseString()
{
Expand All @@ -21,9 +22,19 @@ void testParseString()
assertThat(ItemStatus.parseString("ReJeCtEd"), equalTo(ItemStatus.REJECTED));
}

// [utest->dsn~specification-item~4]
@Test
void testParseUnknownStringThrowsException()
{
assertThrows(IllegalArgumentException.class, () -> ItemStatus.parseString("Unkown"));
final IllegalArgumentException exception = assertThrows(IllegalArgumentException.class,
() -> ItemStatus.parseString("unknown"));
assertThat(exception.getMessage(), equalTo("Unrecognized specification item status: \"unknown\""));
}
}

// [utest->dsn~specification-item~4]
@Test
void testParseUnknownStringAsUnknown()
{
assertThat(ItemStatus.parseOrUnknown("in review"), equalTo(ItemStatus.UNKNOWN));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void assertSimpleItemComplete(final SpecificationItem item)
assertThat(item.getComment(), equalTo(COMMENT));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testBuildComplexSpecificationItem()
{
Expand Down Expand Up @@ -118,7 +118,7 @@ void testNeedsCoverageByArtifactType()
assertThat(item.needsCoverageByArtifactType(NOT_NEEDED_ARTIFACT_TYPE), equalTo(false));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testNeedsCoverage()
{
Expand All @@ -128,7 +128,7 @@ void testNeedsCoverage()
assertThat(builder.build().needsCoverage(), equalTo(true));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testLocationIsNullByDefault()
{
Expand Down Expand Up @@ -178,52 +178,52 @@ void testDependencyBuilderWithIdParts()
assertThat(item.getDependOnIds(), equalTo(parseIds("foo~bar~3")));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testDefaultStatusIsApproved()
{
assertThat(createTestItemBuilder().build().getStatus(), equalTo(ItemStatus.APPROVED));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testBuildWithStatus()
{
assertThat(createTestItemBuilder().status(ItemStatus.REJECTED).build().getStatus(),
equalTo(ItemStatus.REJECTED));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testByDefaultTagListIsEmpty()
{
assertThat(createTestItemBuilder().build().getTags(), emptyIterable());
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testTagBuilder()
{
assertThat(createTestItemBuilder().addTag("the_tag").build().getTags(),
containsInAnyOrder("the_tag"));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testBuildingWithOutIdThrowsExepction()
{
final Builder builder = item();
assertThrows(IllegalStateException.class, builder::build);
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testForwardsIsFalseByDefault()
{
assertThat(createSimpleItem().build().isForwarding(), equalTo(false));
}

// [utest->dsn~specification-item~3]
// [utest->dsn~specification-item~4]
@Test
void testSetForwards()
{
Expand Down
1 change: 1 addition & 0 deletions doc/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ nav_order: 9

# Changes

* [4.12.2](changes_4.12.2.md) unreleased
* [4.12.1](changes_4.12.1.md) unreleased
* [4.12.0](changes_4.12.0.md)
* [4.11.0](changes_4.11.0.md)
Expand Down
7 changes: 7 additions & 0 deletions doc/changes/changes_4.12.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# OpenFastTrace 4.12.2, Unreleased on GitHub

In this release we added a warning if a Markdown or reStructuredText file contain a status that OFT does not support. The status is then registered as `UNKNOWN`.

## Bug Fixes

* #646: Warn about unknown status values in Markdown and reStructuredText specifications
4 changes: 2 additions & 2 deletions doc/developer_guide/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To use OpenFastTrace as a dependency in your [Maven](https://maven.apache.org) p
<dependency>
<groupId>org.itsallcode.openfasttrace</groupId>
<artifactId>openfasttrace</artifactId>
<version>4.12.1</version>
<version>4.12.2</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand All @@ -38,7 +38,7 @@ To use OpenFastTrace as a dependency in your [Gradle](https://gradle.org/) proje

```groovy
dependencies {
compile "org.itsallcode.openfasttrace:openfasttrace:4.12.1"
compile "org.itsallcode.openfasttrace:openfasttrace:4.12.2"
}
```

Expand Down
26 changes: 21 additions & 5 deletions doc/spec/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,21 @@ Needs: impl, utest, itest

RST and Markdown share a common underlying parser that operates on a line-by-line basis.

##### Lightweight-Markup Specification-Item Status
`dsn~lightweight-markup.specification-item-status~2`

The shared line parser imports a `Status:` declaration as the current
specification item's `ItemStatus` when its value is `approved`, `proposed`,
`draft`, or `rejected`. For any other value, it assigns `UNKNOWN` and reports a
warning.

Covers:

* `req~specification-item~3`
* `req~report-unknown-lightweight-markup-statuses~1`

Needs: impl, utest, itest

##### Markdown Comment Coverage Tags
`dsn~markdown.comment-coverage-tags~1`

Expand Down Expand Up @@ -895,13 +910,14 @@ Needs: impl, utest
### Internal Data Structures

#### Specification Item
`dsn~specification-item~3`
`dsn~specification-item~4`

A `SpecificationItem` consists of the following parts:

* ID (`SpecificationItemId`)
* Title (`String`, optional)
* Status (`Enum`, optional)
* Status (`ItemStatus`: `APPROVED`, `PROPOSED`, `DRAFT`, `REJECTED`, or
`UNKNOWN`; optional)
* Description (`String`, optional)
* Rationale (`String`, optional)
* Comment (`String`, optional)
Expand All @@ -918,7 +934,7 @@ See `req~forwarding_needed_coverage~1` for an explanation of the "forwards" fiel

Covers:

* `req~specification-item~2`
* `req~specification-item~3`
* `req~forwarding_needed_coverage~1`

Needs: impl, utest
Expand All @@ -933,7 +949,7 @@ This allows navigating between specification items.

Covers:

* `req~specification-item~2`
* `req~specification-item~3`

Needs: impl, utest

Expand All @@ -948,7 +964,7 @@ A `SpecificationItemId` consists of:

Covers:

* `req~specification-item~2`
* `req~specification-item~3`

Needs: impl, utest

Expand Down
19 changes: 17 additions & 2 deletions doc/spec/system_requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Needs: req
### Anatomy of Specification Items

#### Specification Item
`req~specification-item~2`
`req~specification-item~3`

A specification item consists of the following parts:

Expand All @@ -272,7 +272,8 @@ The ID is a unique key through which the specification item can be referenced. I

The title is a short summary of the specification item, mostly intended to appear in overview lists.

The status of the item is one of "approved", "proposed", "draft" and "rejected".
If specified, the status of the item must be one of `approved`, `proposed`,
`draft`, or `rejected`.

The description contains the normative part of the specification.

Expand Down Expand Up @@ -383,6 +384,20 @@ Covers:

Needs: dsn

##### Report Unknown Lightweight-Markup Statuses
`req~report-unknown-lightweight-markup-statuses~1`

OFT reports a warning when a Markdown or reStructuredText parser encounters a
`Status:` declaration whose value does not identify a known specification-item
status.

Covers:

* [feat~markdown-import~1](#markdown-import)
* [feat~rst-import~1](#restructured-text-rst-import)

Needs: dsn

#### Markdown

Markdown is a simple ASCII-based markup format that is designed to be human-readable in the source. While it can be rendered into HTML, it is perfectly eye-friendly even before rendering.
Expand Down
5 changes: 3 additions & 2 deletions doc/user_guide/use_cases/writing_a_specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,15 @@ Keywords are followed by a colon that separates the keyword from the content. De

##### `Status`

The `Status` keyword takes a single value from `draft`, `proposed`, `approved`, `rejected` to set the status of the item. The status can be used to filter specification items during import (see [Import options](../reference/oft_command_line.md#import-options)). Has to occur before the `Description`, `Rationale` or `Comment`.
The `Status` keyword takes a single value from `draft`, `proposed`, `approved`, `rejected` to set the status of the item.
OFT reports a warning for any other value.
The status can be used to filter specification items during import (see [Import options](../reference/oft_command_line.md#import-options)). Has to occur before the `Description`, `Rationale` or `Comment`.

### A draft spec items
`req~draft-item~1`
Status: draft

This spec item is in the draft state and thus not considered final.


##### `Covers`

Expand Down
Loading
Loading