1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.flags.custom;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.assertEquals;
public class SharedHostTest {
@Test
public void serialization() throws IOException {
verifySerialization(new SharedHost(List.of(
new HostResources(1.0, 2.0, 3.0, 4.0, "fast", "remote",
"container", 5, "x86_64")), 6));
verifySerialization(new SharedHost(List.of(
new HostResources(1.0, 2.0, 3.0, 4.0, "fast", "remote",
"admin", 5, "arm64")), null));
}
private void verifySerialization(SharedHost sharedHost) throws IOException {
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(sharedHost);
SharedHost deserialized = mapper.readValue(json, SharedHost.class);
assertEquals(sharedHost, deserialized);
}
}
|