package com.yahoo.vespa.hosted.controller.persistence;

import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificateMetadata;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.*;

public class EndpointCertificateMetadataSerializerTest {

    private EndpointCertificateMetadata sample =
            new EndpointCertificateMetadata("keyName", "certName", 1);
    private EndpointCertificateMetadata sampleWithRequestMetadata =
            new EndpointCertificateMetadata("keyName", "certName", 1, "requestId", List.of("SAN1", "SAN2"));

    @Test
    public void serialize() {
        assertEquals(
                "{\"keyName\":\"keyName\",\"certName\":\"certName\",\"version\":1}",
                EndpointCertificateMetadataSerializer.toSlime(sample).toString());
    }

    @Test
    public void serializeWithRequestMetadata() {
        assertEquals(
                "{\"keyName\":\"keyName\",\"certName\":\"certName\",\"version\":1,\"requestId\":\"requestId\",\"requestedDnsSans\":[\"SAN1\",\"SAN2\"]}",
                EndpointCertificateMetadataSerializer.toSlime(sampleWithRequestMetadata).toString());
    }

    @Test
    public void deserializeFromString() {
        assertEquals(
                new EndpointCertificateMetadata("foo-key", "foo-cert", 0),
                EndpointCertificateMetadataSerializer.fromJsonString("foo"));
    }

    @Test
    public void deserializeFromJson() {
        assertEquals(
                sample,
                EndpointCertificateMetadataSerializer.fromJsonString(
                        "{\"keyName\":\"keyName\",\"certName\":\"certName\",\"version\":1}"));
    }

    @Test
    public void deserializeFromJsonWithRequestMetadata() {
        assertEquals(
                sampleWithRequestMetadata,
                EndpointCertificateMetadataSerializer.fromJsonString(
                        "{\"keyName\":\"keyName\",\"certName\":\"certName\",\"version\":1,\"requestId\":\"requestId\",\"requestedDnsSans\":[\"SAN1\",\"SAN2\"]}"));
    }
}
@@ -1172,242 +1172,8 @@
  %7D%0A%0A
-    @Test%0A    public void deserializeFromString() %7B%0A        assertEquals(%0A                new EndpointCertificateMetadata(%22foo-key%22, %22foo-cert%22, 0),%0A                EndpointCertificateMetadataSerializer.fromJsonString(%22foo%22));%0A    %7D%0A%0A
     

remove superfluous test