package alien4cloud.rest.utils;

import com.sun.javafx.scene.shape.PathUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;

public class PatchUtilTest {

    private TestObject testObject;

    @Before
    public void setUp(){
        testObject = new TestObject();
        testObject.map.put("a","1");
        testObject.map.put("b","2");
    }

    @Test
    public void check_a_patch_can_update_a_value() throws Exception {
        Map<String, String> patch = new HashMap<String, String>() {{
            put("a", "2");
        }};

        PatchUtil.setMap(testObject.getMap(), patch, true);

        assertThat(testObject.getMap()).containsEntry("a","2").containsEntry("b", "2");
    }

    @Test
    public void check_a_patch_can_add_an_entry() throws Exception {
        Map<String, String> patch = new HashMap<String, String>() {{
            put("c", "3");
        }};

        PatchUtil.setMap(testObject.getMap(), patch, true);

        assertThat(testObject.getMap()).containsEntry("a","1").containsEntry("b", "2").containsEntry("c", "3");
    }

    @Test
    public void check_a_patch_can_remove_a_value_1() throws Exception {
        Map<String, String> patch = new HashMap<String, String>() {{
            put("a", null);
        }};

        PatchUtil.setMap(testObject.getMap(), patch, true);

        assertThat(testObject.getMap()).hasSize(1);
        assertThat(testObject.getMap()).containsEntry("b", "2");
    }

    @Test
    public void check_a_patch_can_remove_a_value_2() throws Exception {
        Map<String, String> patch = new HashMap<String, String>() {{
            put("a", "null");
        }};

        PatchUtil.setMap(testObject.getMap(), patch, true);

        assertThat(testObject.getMap()).hasSize(1);
        assertThat(testObject.getMap()).containsEntry("b", "2");
    }

    @Test
    public void check_an_update_override_everything() throws Exception {
        Map<String, String> patch = new HashMap<String, String>() {{
            put("d", "4");
        }};

        PatchUtil.setMap(testObject.getMap(), patch, false);

        assertThat(testObject.getMap()).hasSize(1);
        assertThat(testObject.getMap()).containsEntry("d", "4");
    }

    @Getter
    @Setter
    @ToString
    private static class TestObject {
        private Map<String, String> map = new HashMap<>();
    }

}
@@ -37,333 +37,224 @@
 ort 
-com.sun.javafx.scene.shape.PathUtils;%0Aimport lombok.Getter;%0Aimport lombok.Setter;%0Aimport lombok.ToString;%0Aimport org.assertj.core.api.Assertions;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport static org.assertj.core.api.Assertions.*;%0Aimport static org.junit.Assert.*
+static org.assertj.core.api.Assertions.assertThat;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport lombok.Getter;%0Aimport lombok.Setter;%0Aimport lombok.ToString
 ;%0A%0Ap

Fix wrong import