summaryrefslogtreecommitdiffstats
path: root/flags/src/test/java/com/yahoo/vespa/flags/custom/SharedHostTest.java
blob: f0a11f244a4d97399027c9235530bd4e3722e438 (plain) (blame)
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
// Copyright Verizon Media. 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", 5)), 6));
        verifySerialization(new SharedHost(List.of(new HostResources(1.0, 2.0, 3.0, 4.0, "fast", "remote", 5)), 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);
    }
}