package thb.jeanluc.adventure.save;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;

class SaveDataTest {

    @Test
    void roundTripsThroughJackson() throws Exception {
        SaveData data = new SaveData(
                1, "Haunted Manor", "slot-a", 1700000000000L, 7,
                "library", List.of("kitchen", "library"), 3,
                List.of("key"), List.of("power_on"),
                Map.of("restore_power", 1), List.of("intro"),
                Map.of("cellar", List.of("shovel")), Map.of("lamp", true));
        ObjectMapper mapper = new ObjectMapper();
        String json = mapper.writeValueAsString(data);
        SaveData back = mapper.readValue(json, SaveData.class);
        assertThat(back).isEqualTo(data);
        assertThat(back.currentRoomId()).isEqualTo("library");
        assertThat(back.switchStates()).containsEntry("lamp", true);
    }
}
