aboutsummaryrefslogtreecommitdiffstats
path: root/config-lib/src/test/java/com/yahoo/config/ModelNodeTest.java
blob: b118c406e36a7d534b36c31e1b32a4d8ebba5365 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config;

import org.junit.jupiter.api.Test;

import java.nio.file.Path;
import java.util.Optional;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @author bratseth
 */
public class ModelNodeTest {

    @Test
    void testEmpty() {
        assertEquals("(null)", new ModelNode().toString());
    }

    @Test
    void testUnresolvedReference() {
        var reference = ModelReference.unresolved(Optional.of("myModelId"),
                                                  Optional.of(new UrlReference("https://host:my/path")),
                                                  Optional.of(new FileReference("foo.txt")));
        assertEquals("myModelId https://host:my/path foo.txt", reference.toString());
        assertEquals(reference, ModelReference.valueOf(reference.toString()));
    }

    @Test
    void testResolvedReference() {
        var reference = ModelReference.resolved(Path.of("dir/resolvedFile.txt"));
        assertEquals("dir/resolvedFile.txt", reference.toString());
        assertEquals(reference, ModelReference.valueOf(reference.toString()));
    }

}