Skip to content

Commit

Permalink
Upgrades structurizr-* to 2.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrowndotje committed Mar 2, 2024
1 parent f777a11 commit 125b218
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 19 deletions.
6 changes: 3 additions & 3 deletions structurizr-onpremises/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ dependencies {

implementation project(':structurizr-onpremises-plugin')

implementation 'com.structurizr:structurizr-dsl:2.0.0'
implementation 'com.structurizr:structurizr-inspection:2.0.0'
implementation 'com.structurizr:structurizr-autolayout:2.0.0'
implementation 'com.structurizr:structurizr-dsl:2.1.0'
implementation 'com.structurizr:structurizr-inspection:2.1.0'
implementation 'com.structurizr:structurizr-autolayout:2.1.0'

compileOnly 'jakarta.servlet:jakarta.servlet-api:6.0.0'
implementation 'jakarta.servlet.jsp.jstl:jakarta.servlet.jsp.jstl-api:3.0.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public void test() throws Exception {
assertEquals(1, workspaceId);

WorkspaceMetaData workspaceMetaData = workspaceComponent.getWorkspaceMetaData(1);
String jsonV1 = String.format("{\"id\":1,\"name\":\"Workspace 0001\",\"description\":\"Description\",\"revision\":1,\"lastModifiedDate\":\"%s\",\"configuration\":{},\"model\":{},\"documentation\":{},\"views\":{\"configuration\":{\"branding\":{},\"styles\":{},\"terminology\":{}}}}", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()));
String jsonV1 = String.format("""
{"configuration":{},"description":"Description","documentation":{},"id":1,"lastModifiedDate":"%s","model":{},"name":"Workspace 0001","revision":1,"views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()));
assertEquals(jsonV1, workspaceComponent.getWorkspace(1, ""));

Collection<WorkspaceMetaData> workspaces = workspaceComponent.getWorkspaces();
Expand All @@ -69,7 +70,8 @@ public void test() throws Exception {
workspaceComponent.putWorkspace(1, json);

workspaceMetaData = workspaceComponent.getWorkspaceMetaData(1);
String jsonV2 = String.format("{\"id\":1,\"name\":\"Financial Risk System\",\"description\":\"...\",\"revision\":2,\"lastModifiedDate\":\"%s\",\"configuration\":{},\"model\":{},\"documentation\":{},\"views\":{\"configuration\":{\"branding\":{},\"styles\":{},\"terminology\":{}}}}", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()));
String jsonV2 = String.format("""
{"configuration":{},"description":"...","documentation":{},"id":1,"lastModifiedDate":"%s","model":{},"name":"Financial Risk System","revision":2,"views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()));
assertEquals(jsonV2, workspaceComponent.getWorkspace(1, ""));

workspaceVersions = workspaceComponent.getWorkspaceVersions(1, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ public void putWorkspace(WorkspaceMetaData workspaceMetaData, String json) {
long workspaceId = workspaceComponent.createWorkspace(null);

assertEquals(1, workspaceId);
assertEquals(String.format("{\"id\":1,\"name\":\"Workspace 0001\",\"description\":\"Description\",\"revision\":1,\"lastModifiedDate\":\"%s\",\"configuration\":{},\"model\":{},\"documentation\":{},\"views\":{\"configuration\":{\"branding\":{},\"styles\":{},\"terminology\":{}}}}", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate())), jsonBuffer.toString());
assertEquals(String.format("""
{"configuration":{},"description":"Description","documentation":{},"id":1,"lastModifiedDate":"%s","model":{},"name":"Workspace 0001","revision":1,"views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate())), jsonBuffer.toString());
}

@Test
Expand Down Expand Up @@ -263,7 +264,8 @@ public String getWorkspace(long workspaceId, String version) {

WorkspaceComponent workspaceComponent = new WorkspaceComponentImpl(dao, "password");
String json = workspaceComponent.getWorkspace(1, "");
assertEquals("{\"id\":1,\"name\":\"Name\",\"description\":\"Description\",\"configuration\":{},\"model\":{},\"documentation\":{},\"views\":{\"configuration\":{\"branding\":{},\"styles\":{},\"terminology\":{}}}}", json);
assertEquals("""
{"configuration":{},"description":"Description","documentation":{},"id":1,"model":{},"name":"Name","views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""", json);
}

@Test
Expand Down Expand Up @@ -312,15 +314,18 @@ public void putWorkspace(WorkspaceMetaData workspaceMetaData, String json) {
}
};

String expectedJson = """
{"configuration":{},"description":"Description","documentation":{},"id":1,"lastModifiedDate":"%s","model":{},"name":"Name","revision":%s,"views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""";

WorkspaceComponent workspaceComponent = new WorkspaceComponentImpl(dao, "");
workspaceComponent.putWorkspace(1, json);
assertEquals(String.format("{\"id\":1,\"name\":\"Name\",\"description\":\"Description\",\"revision\":1,\"lastModifiedDate\":\"%s\",\"configuration\":{},\"model\":{},\"documentation\":{},\"views\":{\"configuration\":{\"branding\":{},\"styles\":{},\"terminology\":{}}}}", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate())), jsonBuffer.toString());
assertEquals(String.format(expectedJson, DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()), "1"), jsonBuffer.toString());

// and again, to increment the revision
json = jsonBuffer.toString();
jsonBuffer.setLength(0);
workspaceComponent.putWorkspace(1, json);
assertEquals(String.format("{\"id\":1,\"name\":\"Name\",\"description\":\"Description\",\"revision\":2,\"lastModifiedDate\":\"%s\",\"configuration\":{},\"model\":{},\"documentation\":{},\"views\":{\"configuration\":{\"branding\":{},\"styles\":{},\"terminology\":{}}}}", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate())), jsonBuffer.toString());
assertEquals(String.format(expectedJson, DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()), "2"), jsonBuffer.toString());
}

@Test
Expand All @@ -344,14 +349,17 @@ public void putWorkspace(WorkspaceMetaData workspaceMetaData, String json) {

WorkspaceComponent workspaceComponent = new WorkspaceComponentImpl(dao, "password");
workspaceComponent.putWorkspace(1, json);
assertTrue(jsonBuffer.toString().startsWith(String.format("{\"id\":1,\"name\":\"Name\",\"description\":\"Description\",\"revision\":1,\"lastModifiedDate\":\"%s\",\"configuration\":{},\"ciphertext\"", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()))));
String pattern = """
"id":1,"lastModifiedDate":"%s","name":"Name","revision":%s}""";
assertTrue(jsonBuffer.toString().startsWith("{\"ciphertext\":\""));
assertTrue(jsonBuffer.toString().endsWith(String.format(pattern, DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()), "1")));

// and again, to increment the revision
json = jsonBuffer.toString();
jsonBuffer.setLength(0);
workspaceComponent.putWorkspace(1, json);
System.out.println(jsonBuffer);
assertTrue(jsonBuffer.toString().startsWith(String.format("{\"id\":1,\"name\":\"Name\",\"description\":\"Description\",\"revision\":2,\"lastModifiedDate\":\"%s\",\"configuration\":{},\"ciphertext\"", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()))));
assertTrue(jsonBuffer.toString().startsWith("{\"ciphertext\":\""));
assertTrue(jsonBuffer.toString().endsWith(String.format(pattern, DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()), "2")));
}

@Test
Expand Down Expand Up @@ -380,15 +388,17 @@ public void putWorkspace(WorkspaceMetaData workspaceMetaData, String json) {

WorkspaceComponent workspaceComponent = new WorkspaceComponentImpl(dao, "");
workspaceComponent.putWorkspace(1, json);
assertTrue(jsonBuffer.toString().startsWith(String.format("{\"id\":1,\"name\":\"Name\",\"description\":\"Description\",\"revision\":1,\"lastModifiedDate\":\"%s\",\"configuration\":{},\"ciphertext\"", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()))));
assertTrue(jsonBuffer.toString().endsWith((json.substring(json.indexOf("ciphertext")))));
String pattern = """
"id":1,"lastModifiedDate":"%s","name":"Name","revision":%s}""";
assertTrue(jsonBuffer.toString().startsWith("{\"ciphertext\":\""));
assertTrue(jsonBuffer.toString().endsWith(String.format(pattern, DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()), "1")));

// and again, to increment the revision
json = jsonBuffer.toString();
jsonBuffer.setLength(0);
workspaceComponent.putWorkspace(1, json);
assertTrue(jsonBuffer.toString().startsWith(String.format("{\"id\":1,\"name\":\"Name\",\"description\":\"Description\",\"revision\":2,\"lastModifiedDate\":\"%s\",\"configuration\":{},\"ciphertext\"", DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()))));
assertTrue(jsonBuffer.toString().endsWith((json.substring(json.indexOf("ciphertext")))));
assertTrue(jsonBuffer.toString().startsWith("{\"ciphertext\":\""));
assertTrue(jsonBuffer.toString().endsWith(String.format(pattern, DateUtils.formatIsoDate(workspaceMetaData.getLastModifiedDate()), "2")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public WorkspaceMetaData getWorkspaceMetaData(long workspaceId) {
Workspace workspace = new Workspace("Name", "Description");
String json = WorkspaceUtils.toJson(workspace, false);

request.addHeader(HttpHeaders.AUTHORIZATION, "key:ZDc3MTcxNGJjYmZhNjM4NmE4ODk0MmQ5OGQ1MmIwYzUyMjk3ODVmMDZiNjI1YWFiZTdlMjZmZmYyNmFmN2QzNw==");
request.addHeader(HttpHeaders.AUTHORIZATION, "key:YjUxOTBkNjg5NjI5MjRiMzZjNWQwZmEwYjE3ZmI4OWFmNjY4NmY3MjEzZWRkNGE5ZjJmZTFjMDhjZmU0OGNlZg==");
request.addHeader(HttpHeaders.NONCE, "1234567890");
request.addHeader(HttpHeaders.CONTENT_MD5, Base64.getEncoder().encodeToString(new Md5Digest().generate(json).getBytes()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
String view = controller.showPublicJson(1, "version", model);
assertEquals("json", view);
assertEquals("""
{"id":0,"name":"Name","description":"Description","configuration":{},"model":{},"documentation":{},"views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""", model.getAttribute("json"));
{"configuration":{},"description":"Description","documentation":{},"id":0,"model":{},"name":"Name","views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""", model.getAttribute("json"));
}

@Test
Expand Down Expand Up @@ -160,7 +160,7 @@ public String getWorkspace(long workspaceId, String version) throws WorkspaceCom
String view = controller.showSharedJson(1, "version", "token", model);
assertEquals("json", view);
assertEquals("""
{"id":0,"name":"Name","description":"Description","configuration":{},"model":{},"documentation":{},"views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""", model.getAttribute("json"));
{"configuration":{},"description":"Description","documentation":{},"id":0,"model":{},"name":"Name","views":{"configuration":{"branding":{},"styles":{},"terminology":{}}}}""", model.getAttribute("json"));
}

}

0 comments on commit 125b218

Please sign in to comment.