Skip to content

Commit e4ccd4d

Browse files
committed
Added test for submitFeatureRequest
1 parent eab3a88 commit e4ccd4d

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/test/java/edu/tamu/app/controller/ProjectControllerTest.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import com.fasterxml.jackson.databind.JsonMappingException;
2828
import com.fasterxml.jackson.databind.ObjectMapper;
2929

30+
import edu.tamu.app.exception.UserNotFoundException;
31+
import edu.tamu.app.model.FeatureProposal;
3032
import edu.tamu.app.model.response.Project;
3133
import edu.tamu.app.service.ProjectService;
3234
import edu.tamu.weaver.response.ApiResponse;
@@ -35,6 +37,9 @@
3537
@RunWith(SpringRunner.class)
3638
public class ProjectControllerTest {
3739

40+
private static String TEST_FEATURE_PROPOSAL_NAME = "Test FP name";
41+
private static String TEST_FEATURE_PROPOSAL_DESCRIPTION = "Test FP name";
42+
private static FeatureProposal TEST_FEATURE_PROPOSAL = new FeatureProposal(TEST_FEATURE_PROPOSAL_NAME, TEST_FEATURE_PROPOSAL_DESCRIPTION);
3843
private static List<Project> projects = new ArrayList<Project>();
3944

4045
@Value("classpath:mock/projects.json")
@@ -52,9 +57,11 @@ public class ProjectControllerTest {
5257
@Before
5358
public void setup() throws JsonParseException, JsonMappingException, IOException {
5459
MockitoAnnotations.initMocks(this);
55-
projects = objectMapper.readValue(resource.getFile(), new TypeReference<List<Project>>() {});
60+
projects = objectMapper.readValue(resource.getFile(), new TypeReference<List<Project>>() {
61+
});
5662
when(projectService.getAll()).thenReturn(new ApiResponse(SUCCESS, projects));
5763
when(projectService.getById(any(Long.class))).thenReturn(new ApiResponse(SUCCESS, projects.get(0)));
64+
when(projectService.submitFeatureRequest(any(FeatureProposal.class))).thenReturn(new ApiResponse(SUCCESS, TEST_FEATURE_PROPOSAL));
5865
}
5966

6067
@Test
@@ -81,4 +88,10 @@ public void getById() throws JsonParseException, JsonMappingException, Malformed
8188
assertEquals("Project did not have the correct name!", projects.get(0).getName(), project.getName());
8289
}
8390

91+
@Test
92+
public void testSubmitFeatureRequest() throws UserNotFoundException {
93+
ApiResponse response = projectController.submitFeatureRequest(TEST_FEATURE_PROPOSAL);
94+
assertEquals("Request was not successfull", SUCCESS, response.getMeta().getStatus());
95+
}
96+
8497
}

0 commit comments

Comments
 (0)