package com.ufund.api.ufundapi.model;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import com.ufund.api.ufundapi.model.Need.GoalType;

@Tag("Model-tier")
public class NeedTest {

    @Test
    public void createNeed() {

        String name = "Jellyfish";
        double maxGoal = 100.00;
        GoalType type = GoalType.MONETARY;
        Need need = new Need(name, type, maxGoal);
        assertNotNull(need);
    }

    @Test
    public void testFields() {
        String name = "Jellyfish";
        int id = 0;
        double maxGoal = 100.00;
        GoalType type = GoalType.MONETARY;
        Need need = new Need(name, type, maxGoal);

       
        assertEquals(name, need.getName());
        assertEquals(id, need.getId());
        assertEquals(maxGoal, need.getMaxGoal());
        assertEquals(type, need.getType());
    }

    @Test
    public void testCurrentGoal() {
        String name = "Jellyfish";
        double maxGoal = 100.00;
        GoalType type = GoalType.MONETARY;
        Need need = new Need(name, type, maxGoal);

        double current = 0.00;
        need.setCurrent(current);
        assertEquals(current, need.getCurrent());

        current = 100.00;
        need.setCurrent(current);
        assertEquals(current, need.getCurrent());

        current = -100.00;
        need.setCurrent(current);
        assertEquals(current, need.getCurrent());

    }

    @Test
    public void testFilterAttributes() {

        String name = "Jellyfish";
        double maxGoal = 100.00;
        GoalType type = GoalType.MONETARY;
        Need need = new Need(name, type, maxGoal);

        String[] filterAttributes = {"seaweed", "divers", "pacific", "plankton"};

        need.setFilterAttributes(filterAttributes);

        assertEquals(need.getFilterAttributes(), filterAttributes);
    }

    @Test
    public void testSetMaxGoal() {

        String name = "Jellyfish";
        double maxGoal = 100.00;
        GoalType type = GoalType.MONETARY;
        Need need = new Need(name, type, maxGoal);

        double newGoal = 200.00;
        need.setMaxGoal(newGoal);


        assertEquals(newGoal, need.getMaxGoal());
    }

    @Test
    public void testSetName() {

        String name = "Jellyfish";
        double maxGoal = 100.00;
        GoalType type = GoalType.MONETARY;
        Need need = new Need(name, type, maxGoal);

        String newName = "TESTINGFUN";
        need.setName(newName);

        assertEquals(newName, need.getName());
    }

}