2727import com .fasterxml .jackson .databind .JsonMappingException ;
2828import com .fasterxml .jackson .databind .ObjectMapper ;
2929
30+ import edu .tamu .app .exception .UserNotFoundException ;
31+ import edu .tamu .app .model .FeatureProposal ;
3032import edu .tamu .app .model .response .Project ;
3133import edu .tamu .app .service .ProjectService ;
3234import edu .tamu .weaver .response .ApiResponse ;
3537@ RunWith (SpringRunner .class )
3638public 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