This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 265
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a "default" keyword, for setting the default view.
- Loading branch information
1 parent
567fe9c
commit 06c6b3a
Showing
12 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.structurizr.dsl; | ||
|
||
import com.structurizr.view.View; | ||
|
||
final class DefaultViewParser extends AbstractParser { | ||
|
||
void parse(ViewDslContext context) { | ||
View view = context.getView(); | ||
context.getWorkspace().getViews().getConfiguration().setDefaultView(view); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/com/structurizr/dsl/FilteredViewDslContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.structurizr.dsl; | ||
|
||
import com.structurizr.view.FilteredView; | ||
|
||
class FilteredViewDslContext extends ViewDslContext { | ||
|
||
FilteredViewDslContext(FilteredView view) { | ||
super(view); | ||
} | ||
|
||
FilteredView getView() { | ||
return (FilteredView)super.getView(); | ||
} | ||
|
||
@Override | ||
protected String[] getPermittedTokens() { | ||
return new String[] { | ||
StructurizrDslTokens.DEFAULT_VIEW_TOKEN, | ||
StructurizrDslTokens.VIEW_TITLE_TOKEN, | ||
StructurizrDslTokens.VIEW_DESCRIPTION_TOKEN, | ||
StructurizrDslTokens.PROPERTIES_TOKEN | ||
}; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/test/java/com/structurizr/dsl/DefaultViewParserTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.structurizr.dsl; | ||
|
||
import com.structurizr.view.SystemLandscapeView; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
class DefaultViewParserTests extends AbstractTests { | ||
|
||
private final DefaultViewParser parser = new DefaultViewParser(); | ||
|
||
@Test | ||
void test_parse_SetsTheDefaultView() { | ||
SystemLandscapeView view = workspace.getViews().createSystemLandscapeView("key", "description"); | ||
SystemLandscapeViewDslContext context = new SystemLandscapeViewDslContext(view); | ||
context.setWorkspace(workspace); | ||
|
||
assertNull(context.getWorkspace().getViews().getConfiguration().getDefaultView()); | ||
parser.parse(context); | ||
assertEquals("key", context.getWorkspace().getViews().getConfiguration().getDefaultView()); | ||
} | ||
|
||
} |