package org.apereo.cas.services;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.val;
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;

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

/**
 * @author Misagh Moayyed
 * @since 4.1
 */
@Tag("RegisteredService")
public class RegisteredServicePublicKeyImplTests {

    private static final File JSON_FILE = new File(FileUtils.getTempDirectoryPath(), "registeredServicePublicKeyImpl.json");
    private static final ObjectMapper MAPPER = new ObjectMapper().findAndRegisterModules();

    @Test
    public void verifySerializeAX509CertificateCredentialToJson() throws IOException {
        val publicKeyWritten = new RegisteredServicePublicKeyImpl("location", "algorithm");
        MAPPER.writeValue(JSON_FILE, publicKeyWritten);
        val credentialRead = MAPPER.readValue(JSON_FILE, RegisteredServicePublicKeyImpl.class);
        assertEquals(publicKeyWritten, credentialRead);
    }
}

@@ -232,36 +232,8 @@
 ile;
-%0Aimport java.io.IOException;
 %0A%0Aim
@@ -528,24 +528,25 @@
 mpl.json%22);%0A
+%0A
     private 
@@ -713,10 +713,8 @@
 ows 
-IO
 Exce
@@ -965,16 +965,16 @@
 class);%0A
-
         
@@ -1026,11 +1026,319 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void verifyInstance() %7B%0A        val key1 = new RegisteredServicePublicKeyImpl(%22classpath:keys/RSA1024Public.key%22, %22RSA%22);%0A        assertNotNull(key1.createInstance());%0A%0A        val key2 = new RegisteredServicePublicKeyImpl(null, %22RSA%22);%0A        assertNull(key2.createInstance());%0A    %7D
 %0A%7D%0A

add tests