aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-athenz/src/test/java/com/yahoo/vespa/athenz/identityprovider/api/VespaUniqueInstanceIdTest.java
blob: d22a791fa60d0072299d7fd415cafa63e17d9906 (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 Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.athenz.identityprovider.api;

import org.junit.jupiter.api.Test;

import static com.yahoo.vespa.athenz.identityprovider.api.IdentityType.*;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @author bjorncs
 */
public class VespaUniqueInstanceIdTest {

    @Test
    void can_serialize_to_and_deserialize_from_string() {
        VespaUniqueInstanceId id =
                new VespaUniqueInstanceId(1, "cluster-id", "instance", "application", "tenant", "region", "environment", TENANT);
        String stringRepresentation = id.asDottedString();
        String expectedStringRepresentation = "1.cluster-id.instance.application.tenant.region.environment.tenant";
        assertEquals(expectedStringRepresentation, stringRepresentation);
        VespaUniqueInstanceId deserializedId = VespaUniqueInstanceId.fromDottedString(stringRepresentation);
        assertEquals(id, deserializedId);
    }

}