aboutsummaryrefslogtreecommitdiff
path: root/ufund-api/src/test/java/com/ufund/api/ufundapi/model/NeedTest.java
blob: c7d17c76931996b69c854337970f58de23b4a2c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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";
        String location = "Atlantis";
        double maxGoal = 100.0;
        GoalType type = Need.GoalType.MONETARY;
        boolean urgent = false;
        var need = new Need(name, location, maxGoal, type, urgent);
        assertNotNull(need);
    }

    @Test
    public void testFields() {
        String name = "Jellyfish";
        String location = "Atlantis";
        double maxGoal = 100.0;
        GoalType type = Need.GoalType.MONETARY;
        boolean urgent = false;
        var need = new Need(name, location, maxGoal, type, urgent);

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

    @Test
    public void testCurrentGoal() {
        String name = "Jellyfish";
        String location = "Atlantis";
        double maxGoal = 100.0;
        GoalType type = Need.GoalType.MONETARY;
        boolean urgent = false;
        var need = new Need(name, location, maxGoal, type, urgent);

        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";
        String location = "Atlantis";
        double maxGoal = 100.0;
        GoalType type = Need.GoalType.MONETARY;
        boolean urgent = false;
        var need = new Need(name, location, maxGoal, type, urgent);

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

        need.setFilterAttributes(filterAttributes);

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

    @Test
    public void testSetMaxGoal() {

        String name = "Jellyfish";
        String location = "Atlantis";
        double maxGoal = 100.0;
        GoalType type = Need.GoalType.MONETARY;
        boolean urgent = false;
        var need = new Need(name, location, maxGoal, type, urgent);

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


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

    @Test
    public void testSetName() {

        String name = "Jellyfish";
        String location = "Atlantis";
        double maxGoal = 100.0;
        GoalType type = Need.GoalType.MONETARY;
        boolean urgent = false;
        var need = new Need(name, location, maxGoal, type, urgent);

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

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

}