-
-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better error messages for image views.
- Loading branch information
1 parent
3fdab62
commit 43ec4c8
Showing
4 changed files
with
95 additions
and
0 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
64 changes: 64 additions & 0 deletions
64
structurizr-dsl/src/test/java/com/structurizr/dsl/ImageViewContentParserTests.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,64 @@ | ||
package com.structurizr.dsl; | ||
|
||
import com.structurizr.view.ImageView; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
class ImageViewContentParserTests extends AbstractTests { | ||
|
||
private ImageViewContentParser parser; | ||
private ImageView imageView; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
imageView = workspace.getViews().createImageView("key"); | ||
} | ||
|
||
@Test | ||
void test_parsePlantUML_ThrowsAnException_WhenUsingAFileNameInRestrictedMode() { | ||
try { | ||
parser = new ImageViewContentParser(true); | ||
parser.parsePlantUML(new ImageViewDslContext(imageView), null, tokens("plantuml", "image.puml")); | ||
fail(); | ||
} catch (Exception e) { | ||
assertEquals("PlantUML source must be specified as a URL when running in restricted mode", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
void test_parseMermaid_ThrowsAnException_WhenUsingAFileNameInRestrictedMode() { | ||
try { | ||
parser = new ImageViewContentParser(true); | ||
parser.parseMermaid(new ImageViewDslContext(imageView), null, tokens("mermaid", "image.puml")); | ||
fail(); | ||
} catch (Exception e) { | ||
assertEquals("Mermaid source must be specified as a URL when running in restricted mode", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
void test_parseKroki_ThrowsAnException_WhenUsingAFileNameInRestrictedMode() { | ||
try { | ||
parser = new ImageViewContentParser(true); | ||
parser.parseKroki(new ImageViewDslContext(imageView), null, tokens("kroki", "plantuml", "image.puml")); | ||
fail(); | ||
} catch (Exception e) { | ||
assertEquals("Kroki source must be specified as a URL when running in restricted mode", e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
void test_parseImage_ThrowsAnException_WhenUsingAFileNameInRestrictedMode() { | ||
try { | ||
parser = new ImageViewContentParser(true); | ||
parser.parseImage(new ImageViewDslContext(imageView), null, tokens("image", "image.png")); | ||
fail(); | ||
} catch (Exception e) { | ||
assertEquals("Images must be specified as a URL when running in restricted mode", e.getMessage()); | ||
} | ||
} | ||
|
||
} |
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,9 @@ | ||
workspace { | ||
|
||
views { | ||
image * "Image" { | ||
image image.png | ||
} | ||
} | ||
|
||
} |