Skip to content

Commit

Permalink
Removes unused documentation section title property.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Mar 5, 2023
1 parent ae91d82 commit 054e58f
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 68 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ subprojects { proj ->

description = 'Structurizr'
group = 'com.structurizr'
version = '1.22.0'
version = '1.22.1'

repositories {
mavenCentral()
Expand Down
6 changes: 5 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 1.22.1 (5th March 2023)

- Removes unused documentation section title property.

## 1.22.0 (5th March 2023)

- Adds documentation to components.
- Adds documentation to components.

## 1.21.0 (26th February 2023)

Expand Down
14 changes: 14 additions & 0 deletions structurizr-core/src/com/structurizr/documentation/Decision.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
public final class Decision extends DocumentationContent {

private String id;
private String title;
private Date date;
private String status;

Expand All @@ -37,6 +38,19 @@ void setId(String id) {
this.id = id;
}

/**
* Gets the title.
*
* @return the title, as a String
*/
public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

/**
* Gets the date of this decision.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ public Documentation() {
* @param section a Section object
*/
public void addSection(Section section) {
checkTitleIsSpecified(section.getTitle());
checkContentIsSpecified(section.getContent());
checkSectionIsUnique(section.getTitle());
checkFormatIsSpecified(section.getFormat());

section.setOrder(calculateOrder());
Expand All @@ -56,14 +54,6 @@ private void checkFormatIsSpecified(Format format) {
}
}

private void checkSectionIsUnique(String title) {
for (Section section : sections) {
if (title.equals(section.getTitle())) {
throw new IllegalArgumentException("A section with a title of " + title + " already exists in this scope.");
}
}
}

private int calculateOrder() {
return sections.size() + 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ public abstract class DocumentationContent {
// elementId is here for backwards compatibility
private String elementId;

private String title;
private String content;
private Format format;

Expand All @@ -29,19 +28,6 @@ void setElementId(String elementId) {
this.elementId = elementId;
}

/**
* Gets the title.
*
* @return the title, as a String
*/
public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

/**
* Gets the content.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ public final class Section extends DocumentationContent {
public Section() {
}

public Section(String title, Format format, String content) {
setTitle(title);
public Section(Format format, String content) {
setFormat(format);
setContent(content);
}
Expand Down Expand Up @@ -55,16 +54,16 @@ public boolean equals(Object object) {

Section section = (Section)object;
if (getElementId() != null) {
return getElementId().equals(section.getElementId()) && getTitle().equals(section.getTitle());
return getElementId().equals(section.getElementId()) && getContent().equals(section.getContent());
} else {
return getTitle().equals(section.getTitle());
return getContent().equals(section.getContent());
}
}

@Override
public int hashCode() {
int result = getElementId() != null ? getElementId().hashCode() : 0;
result = 31 * result + getTitle().hashCode();
result = 31 * result + getContent().hashCode();
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,10 @@ public void setUp() {
documentation = workspace.getDocumentation();
}

@Test
void addSection_ThrowsAnException_WhenTheTitleIsNotSpecified() {
try {
Section section = new Section();

documentation.addSection(section);
fail();
} catch (IllegalArgumentException iae) {
assertEquals("A title must be specified.", iae.getMessage());
}
}

@Test
void addSection_ThrowsAnException_WhenTheContentIsNotSpecified() {
try {
Section section = new Section();
section.setTitle("Title");

documentation.addSection(section);
fail();
Expand All @@ -44,7 +31,6 @@ void addSection_ThrowsAnException_WhenTheContentIsNotSpecified() {
void addSection_ThrowsAnException_WhenTheFormatIsNotSpecified() {
try {
Section section = new Section();
section.setTitle("Title");
section.setContent("Content");

documentation.addSection(section);
Expand All @@ -54,44 +40,26 @@ void addSection_ThrowsAnException_WhenTheFormatIsNotSpecified() {
}
}

@Test
void addSection_ThrowsAnException_WhenASectionExistsWithTheSameTitle() {
try {
Section section = new Section();
section.setTitle("Title");
section.setContent("Content");
section.setFormat(Format.Markdown);

documentation.addSection(section);
documentation.addSection(section);
fail();
} catch (IllegalArgumentException iae) {
assertEquals("A section with a title of Title already exists in this scope.", iae.getMessage());
}
}

@Test
void addSection() {
Section section = new Section();
section.setTitle("Title");
section.setContent("Content");
section.setFormat(Format.Markdown);

documentation.addSection(section);

assertEquals(1, documentation.getSections().size());
assertTrue(documentation.getSections().contains(section));
assertEquals("Title", section.getTitle());
assertEquals(Format.Markdown, section.getFormat());
assertEquals("Content", section.getContent());
assertEquals(1, section.getOrder());
}

@Test
void addSection_IncrementsTheSectionOrderNumber() {
Section section1 = new Section("Title 1", Format.Markdown, "Content");
Section section2 = new Section("Title 2", Format.Markdown, "Content");
Section section3 = new Section("Title 3", Format.Markdown, "Content");
Section section1 = new Section(Format.Markdown, "Content 1");
Section section2 = new Section(Format.Markdown, "Content 2");
Section section3 = new Section(Format.Markdown, "Content 3");

documentation.addSection(section1);
documentation.addSection(section2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ public class SectionTests {

@Test
void construction() {
Section section = new Section("Title", Format.Markdown, "Content");
Section section = new Section(Format.Markdown, "Content");

assertEquals("Title", section.getTitle());
assertEquals(Format.Markdown, section.getFormat());
assertEquals("Content", section.getContent());
}
Expand Down

0 comments on commit 054e58f

Please sign in to comment.