Search in sources :

Example 6 with JsonWriter

use of com.structurizr.io.json.JsonWriter in project java by structurizr.

the class EncryptedWorkspaceTests method test_construction_WhenThreeParametersAreSpecified.

@Test
public void test_construction_WhenThreeParametersAreSpecified() throws Exception {
    JsonWriter jsonWriter = new JsonWriter(false);
    StringWriter stringWriter = new StringWriter();
    jsonWriter.write(workspace, stringWriter);
    encryptedWorkspace = new EncryptedWorkspace(workspace, stringWriter.toString(), encryptionStrategy);
    assertEquals("Name", encryptedWorkspace.getName());
    assertEquals("Description", encryptedWorkspace.getDescription());
    assertEquals("1.2.3", encryptedWorkspace.getVersion());
    assertEquals("simon", encryptedWorkspace.getLastModifiedUser());
    assertEquals("structurizr-java", encryptedWorkspace.getLastModifiedAgent());
    assertEquals(1234, encryptedWorkspace.getId());
    assertSame(workspace, encryptedWorkspace.getWorkspace());
    assertSame(encryptionStrategy, encryptedWorkspace.getEncryptionStrategy());
    assertEquals(stringWriter.toString(), encryptedWorkspace.getPlaintext());
    assertEquals(encryptionStrategy.encrypt(stringWriter.toString()), encryptedWorkspace.getCiphertext());
}
Also used : StringWriter(java.io.StringWriter) JsonWriter(com.structurizr.io.json.JsonWriter) Test(org.junit.Test)

Aggregations

JsonWriter (com.structurizr.io.json.JsonWriter)6 StringWriter (java.io.StringWriter)4 Test (org.junit.Test)3 Workspace (com.structurizr.Workspace)1 EncryptedWorkspace (com.structurizr.encryption.EncryptedWorkspace)1 EncryptedJsonWriter (com.structurizr.io.json.EncryptedJsonWriter)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1 Date (java.util.Date)1 HttpPut (org.apache.hc.client5.http.classic.methods.HttpPut)1 CloseableHttpClient (org.apache.hc.client5.http.impl.classic.CloseableHttpClient)1 CloseableHttpResponse (org.apache.hc.client5.http.impl.classic.CloseableHttpResponse)1 StringEntity (org.apache.hc.core5.http.io.entity.StringEntity)1