+ @Test
+ void getWelcomeResponseIsOkIfRequestIsOfTypeHuman(@Autowired MockMvc mvc) throws Exception
+ {
+ mvc
+ .perform(get("/")
+ .header(REQUEST_TYPE, HUMAN))
+ .andExpect(status().isOk());
+ }
+
+ @Test
+ void expectedResultsForGreetIfRequestIsOfTypeMachine(@Autowired MockMvc mvc) throws Exception
+ {
+ mvc
+ .perform(post("/greet/peter")
+ .header(ACCEPT, "application/json")
+ .header(REQUEST_TYPE, MACHINE)
+ .content("Hello TO_NAME, nice to meet you. I'm FROM_NAME."))
+ .andExpect(status().isOk())
+ .andExpect(content().json("{\"message\": \"Hello peter, nice to meet you. I'm FOO@BAR.\"}"));
+ }
+
+ @Test
+ void expectedResultsForGreetIfRequestIsOfTypeHuman(@Autowired MockMvc mvc) throws Exception
+ {
+ mvc
+ .perform(post("/greet/peter")
+ .header(ACCEPT, "application/json")
+ .header(REQUEST_TYPE, HUMAN)
+ .content("Hello TO_NAME, nice to meet you. I'm FROM_NAME."))
+ .andExpect(status().isOk())
+ .andExpect(content().json("{\"message\": \"Hello peter, nice to meet you. I'm FOO@BAR.\"}"));
+ }
+
+ @Test
+ void badRequestForGreetIfRequestTypeHeaderIsNotSet(@Autowired MockMvc mvc) throws Exception
+ {
+ mvc
+ .perform(post("/greet/peter")
+ .header(ACCEPT, "application/json")
+ .content("Hello TO_NAME, nice to meet you. I'm FROM_NAME."))
+ .andExpect(status().isBadRequest());
+ }
+
+ @Test
+ void expectedResultsForAcknowlegeIfRequestIsOfTypeMachine(@Autowired MockMvc mvc) throws Exception
+ {
+ mvc
+ .perform(post("/acknowledge/peter")
+ .header(ACCEPT, "application/json")
+ .header(REQUEST_TYPE, MACHINE)
+ .content("Hello TO_NAME, nice to meet you. I'm FROM_NAME."))
+ .andExpect(status().isOk())
+ .andExpect(content().json("{\"message\": \"Hello peter, nice to meet you. I'm FOO@BAR.\"}"));
+ }
+
+ @Test
+ void isForbiddenForAcknowlegeIfRequestIsOfTypeHuman(@Autowired MockMvc mvc) throws Exception
+ {
+ mvc
+ .perform(post("/acknowledge/peter")
+ .header(ACCEPT, "application/json")
+ .header(REQUEST_TYPE, HUMAN)
+ .content("Hello TO_NAME, nice to meet you. I'm FROM_NAME."))
+ .andExpect(status().isForbidden());
+ }