aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/TestConfigSerializerTest.java
blob: e28e5dab555605e6672eea61965ce94947774437 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.yahoo.vespa.hosted.controller.deployment;

import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.vespa.config.SlimeUtils;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
import org.junit.Test;

import java.io.IOException;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
import java.util.Map;

import static com.yahoo.vespa.hosted.controller.deployment.InternalDeploymentTester.instanceId;
import static org.junit.Assert.assertEquals;

/**
 * @author jonmv
 */
public class TestConfigSerializerTest {

    @Test
    public void testConfig() throws IOException {
        ZoneId zone = JobType.systemTest.zone(SystemName.PublicCd);
        byte[] json = new TestConfigSerializer(SystemName.PublicCd).configJson(instanceId,
                                                                               JobType.systemTest,
                                                                               true,
                                                                               Map.of(zone, Map.of(ClusterSpec.Id.from("ai"),
                                                                                                   URI.create("https://server/"))),
                                                                               Map.of(zone, List.of("facts")));
        byte[] expected = Files.readAllBytes(Paths.get("src/test/resources/testConfig.json"));
        assertEquals(new String(SlimeUtils.toJsonBytes(SlimeUtils.jsonToSlime(expected))),
                     new String(json));
    }

}