|
@@ -6,12 +6,17 @@
|
|
|
package org.cryptomator.common.settings;
|
|
|
|
|
|
import com.google.gson.stream.JsonReader;
|
|
|
+import com.google.gson.stream.JsonWriter;
|
|
|
+import org.hamcrest.CoreMatchers;
|
|
|
+import org.hamcrest.MatcherAssert;
|
|
|
import org.junit.jupiter.api.Assertions;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.StringReader;
|
|
|
+import java.io.StringWriter;
|
|
|
import java.nio.file.Paths;
|
|
|
+import java.util.Arrays;
|
|
|
|
|
|
public class VaultSettingsJsonAdapterTest {
|
|
|
|
|
@@ -19,7 +24,7 @@ public class VaultSettingsJsonAdapterTest {
|
|
|
|
|
|
@Test
|
|
|
public void testDeserialize() throws IOException {
|
|
|
- String json = "{\"id\": \"foo\", \"path\": \"/foo/bar\", \"mountName\": \"test\", \"winDriveLetter\": \"X\", \"shouldBeIgnored\": true, \"individualMountPath\": \"/home/test/crypto\"}";
|
|
|
+ String json = "{\"id\": \"foo\", \"path\": \"/foo/bar\", \"mountName\": \"test\", \"winDriveLetter\": \"X\", \"shouldBeIgnored\": true, \"individualMountPath\": \"/home/test/crypto\", \"mountFlags\":[\"--foo\", \"--bar\"]}";
|
|
|
JsonReader jsonReader = new JsonReader(new StringReader(json));
|
|
|
|
|
|
VaultSettings vaultSettings = adapter.read(jsonReader);
|
|
@@ -28,6 +33,27 @@ public class VaultSettingsJsonAdapterTest {
|
|
|
Assertions.assertEquals("test", vaultSettings.mountName().get());
|
|
|
Assertions.assertEquals("X", vaultSettings.winDriveLetter().get());
|
|
|
Assertions.assertEquals("/home/test/crypto", vaultSettings.individualMountPath().get());
|
|
|
+ MatcherAssert.assertThat(vaultSettings.mountFlags().get(), CoreMatchers.hasItems("--foo", "--bar"));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testSerialize() throws IOException {
|
|
|
+ VaultSettings vaultSettings = new VaultSettings("test");
|
|
|
+ vaultSettings.path().set(Paths.get("/foo/bar"));
|
|
|
+ vaultSettings.mountName().set("mountyMcMountFace");
|
|
|
+ vaultSettings.mountFlags().set(Arrays.asList("--foo", "--bar"));
|
|
|
+
|
|
|
+ StringWriter buf = new StringWriter();
|
|
|
+ JsonWriter jsonWriter = new JsonWriter(buf);
|
|
|
+ adapter.write(jsonWriter, vaultSettings);
|
|
|
+ String result = buf.toString();
|
|
|
+
|
|
|
+ MatcherAssert.assertThat(result, CoreMatchers.containsString("\"id\":\"test\""));
|
|
|
+ MatcherAssert.assertThat(result, CoreMatchers.containsString("\"path\":\"/foo/bar\""));
|
|
|
+ MatcherAssert.assertThat(result, CoreMatchers.containsString("\"mountName\":\"mountyMcMountFace\""));
|
|
|
+ MatcherAssert.assertThat(result, CoreMatchers.containsString("\"mountFlags\":[\"--foo\",\"--bar\"]"));
|
|
|
}
|
|
|
|
|
|
}
|