use of com.structurizr.Workspace in project java by structurizr.
the class JsonTests method test_backwardsCompatibilityOfRenamingEnterpriseContextViewsToSystemLandscapeViews.
@Test
public void test_backwardsCompatibilityOfRenamingEnterpriseContextViewsToSystemLandscapeViews() throws Exception {
Workspace workspace = new Workspace("Name", "Description");
workspace.getViews().createSystemLandscapeView("key", "description");
JsonWriter jsonWriter = new JsonWriter(false);
StringWriter stringWriter = new StringWriter();
jsonWriter.write(workspace, stringWriter);
String workspaceAsJson = stringWriter.toString();
workspaceAsJson = workspaceAsJson.replaceAll("systemLandscapeViews", "enterpriseContextViews");
JsonReader jsonReader = new JsonReader();
StringReader stringReader = new StringReader(workspaceAsJson);
workspace = jsonReader.read(stringReader);
assertEquals(1, workspace.getViews().getSystemLandscapeViews().size());
}
use of com.structurizr.Workspace in project java by structurizr.
the class JsonTests method test_write_and_read.
@Test
public void test_write_and_read() throws Exception {
final Workspace workspace1 = new Workspace("Name", "Description");
// output the model as JSON
JsonWriter jsonWriter = new JsonWriter(true);
StringWriter stringWriter = new StringWriter();
jsonWriter.write(workspace1, stringWriter);
// and read it back again
JsonReader jsonReader = new JsonReader();
StringReader stringReader = new StringReader(stringWriter.toString());
final Workspace workspace2 = jsonReader.read(stringReader);
assertEquals("Name", workspace2.getName());
assertEquals("Description", workspace2.getDescription());
}
use of com.structurizr.Workspace in project java by structurizr.
the class DefaultLayoutMergeStrategyTests method test_copyLayoutInformation_WhenAnElementNameAndDescriptionAndIdHaveChanged.
@Test
public void test_copyLayoutInformation_WhenAnElementNameAndDescriptionAndIdHaveChanged() {
Workspace workspace1 = new Workspace("1", "");
SoftwareSystem softwareSystem1 = workspace1.getModel().addSoftwareSystem("Software System");
Container container1 = softwareSystem1.addContainer("Container", "Container description", "");
ContainerView view1 = workspace1.getViews().createContainerView(softwareSystem1, "key", "");
view1.add(container1);
view1.getElementView(container1).setX(123);
view1.getElementView(container1).setY(456);
Workspace workspace2 = new Workspace("2", "");
SoftwareSystem softwareSystem2 = workspace2.getModel().addSoftwareSystem("Software System");
// this element has ID 2
softwareSystem2.addContainer("Web Application", "Description", "");
Container container2 = softwareSystem2.addContainer("Database", "Description", "");
ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "key", "");
view2.add(container2);
DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy();
strategy.copyLayoutInformation(view1, view2);
assertEquals(0, view2.getElementView(container2).getX());
assertEquals(0, view2.getElementView(container2).getY());
}
use of com.structurizr.Workspace in project java by structurizr.
the class DefaultLayoutMergeStrategyTests method test_copyLayoutInformation_WhenAnElementNameHasChangedButTheDescriptionHasNotChanged.
@Test
public void test_copyLayoutInformation_WhenAnElementNameHasChangedButTheDescriptionHasNotChanged() {
Workspace workspace1 = new Workspace("1", "");
SoftwareSystem softwareSystem1 = workspace1.getModel().addSoftwareSystem("Software System");
Container container1 = softwareSystem1.addContainer("Container", "Container description", "");
ContainerView view1 = workspace1.getViews().createContainerView(softwareSystem1, "key", "");
view1.add(container1);
view1.getElementView(container1).setX(123);
view1.getElementView(container1).setY(456);
Workspace workspace2 = new Workspace("2", "");
SoftwareSystem softwareSystem2 = workspace2.getModel().addSoftwareSystem("Software System");
Container container2 = softwareSystem2.addContainer("Container with a new name", "Container description", "");
ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "key", "");
view2.add(container2);
DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy();
strategy.copyLayoutInformation(view1, view2);
assertEquals(123, view2.getElementView(container2).getX());
assertEquals(456, view2.getElementView(container2).getY());
}
use of com.structurizr.Workspace in project java by structurizr.
the class DefaultLayoutMergeStrategyTests method test_copyLayoutInformation_WhenAnElementNameAndDescriptionHaveChangedButTheIdHasNotChanged.
@Test
public void test_copyLayoutInformation_WhenAnElementNameAndDescriptionHaveChangedButTheIdHasNotChanged() {
Workspace workspace1 = new Workspace("1", "");
SoftwareSystem softwareSystem1 = workspace1.getModel().addSoftwareSystem("Software System");
Container container1 = softwareSystem1.addContainer("Container", "Container description", "");
ContainerView view1 = workspace1.getViews().createContainerView(softwareSystem1, "key", "");
view1.add(container1);
view1.getElementView(container1).setX(123);
view1.getElementView(container1).setY(456);
Workspace workspace2 = new Workspace("2", "");
SoftwareSystem softwareSystem2 = workspace2.getModel().addSoftwareSystem("Software System");
Container container2 = softwareSystem2.addContainer("Container with a new name", "Container with a new description", "");
ContainerView view2 = workspace2.getViews().createContainerView(softwareSystem2, "key", "");
view2.add(container2);
DefaultLayoutMergeStrategy strategy = new DefaultLayoutMergeStrategy();
strategy.copyLayoutInformation(view1, view2);
assertEquals(123, view2.getElementView(container2).getX());
assertEquals(456, view2.getElementView(container2).getY());
}
Aggregations