package com.github.dikhan.domain;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import junit.framework.AssertionFailedError;
import org.junit.Test;
import sun.jvm.hotspot.utilities.AssertionFailure;

import java.io.IOException;

public class PayloadBuilderTest {

    @Test(expected = IllegalArgumentException.class)
    public void notAbleToCreatePayloadIfMandatoryFieldSummaryIsMissing() {
        Payload.Builder.newBuilder().setSeverity(Severity.INFO).setSource("source").build();
    }

    @Test(expected = IllegalArgumentException.class)
    public void notAbleToCreatePayloadIfMandatoryFieldSourceIsMissing() {
        Payload.Builder.newBuilder().setSeverity(Severity.INFO).setSummary("summary").build();
    }

    @Test(expected = NullPointerException.class)
    public void notAbleToCreatePayloadIfMandatoryFieldSeverityIsMissing() {
        Payload.Builder.newBuilder().setSummary("summary").setSource("source").build();
    }

    @Test
    public void successfulCreation() {
        Payload.Builder.newBuilder().setSummary("summary").setSource("source")
                .setSeverity(Severity.INFO).setCustomDetails("details").build();
    }

    @Test(expected = IllegalArgumentException.class)
    public void testCustomeDetailInvalidJsonFormat() {
        String details = "{\"Name\":\"hello\",}";

        Payload.Builder.newBuilder().setSummary("summary").setSource("source")
                .setSeverity(Severity.INFO).setCustomDetails(details).build();
    }

    @Test
    public void testCustomeDetailWithValidJson() {
        String details = "{\"Name\":\"Hello\"}";

        Payload.Builder.newBuilder().setSummary("summary").setSource("source")
                .setSeverity(Severity.INFO).setCustomDetails(details).build();
    }
}

@@ -39,278 +39,22 @@
 ort 
-com.fasterxml.jackson.databind.ObjectMapper;%0Aimport com.google.gson.JsonParser;%0Aimport com.google.gson.JsonSyntaxException;%0Aimport junit.framework.AssertionFailedError;%0Aimport org.junit.Test;%0Aimport sun.jvm.hotspot.utilities.AssertionFailure;%0A%0Aimport java.io.IOException
+org.junit.Test
 ;%0A%0Ap

Clean up unused imports