Review Comments
This commit is contained in:
		
							parent
							
								
									8999b501c9
								
							
						
					
					
						commit
						4e0b27b017
					
				| @ -36,18 +36,15 @@ class ValidationControllerUnitTest { | |||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void whenNullInputForBooleanField_thenHttpBadRequestAsHttpResponse() throws Exception { |     void whenNullInputForBooleanField_thenHttpBadRequestAsHttpResponse() throws Exception { | ||||||
| 
 |  | ||||||
|         String postBody = "{\"boolField\":null,\"trueField\":true,\"falseField\":false,\"boolStringVar\":\"+\"}"; |         String postBody = "{\"boolField\":null,\"trueField\":true,\"falseField\":false,\"boolStringVar\":\"+\"}"; | ||||||
| 
 | 
 | ||||||
|         mockMvc.perform(post("/validateBoolean").contentType("application/json") |         mockMvc.perform(post("/validateBoolean").contentType("application/json") | ||||||
|             .content(postBody)) |             .content(postBody)) | ||||||
|             .andExpect(status().isBadRequest()); |             .andExpect(status().isBadRequest()); | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void whenInvalidInputForTrueBooleanField_thenErrorResponse() throws Exception { |     void whenInvalidInputForTrueBooleanField_thenErrorResponse() throws Exception { | ||||||
| 
 |  | ||||||
|         String postBody = "{\"boolField\":true,\"trueField\":false,\"falseField\":false,\"boolStringVar\":\"+\"}"; |         String postBody = "{\"boolField\":true,\"trueField\":false,\"falseField\":false,\"boolStringVar\":\"+\"}"; | ||||||
| 
 | 
 | ||||||
|         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") |         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") | ||||||
| @ -61,7 +58,6 @@ class ValidationControllerUnitTest { | |||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void whenInvalidInputForFalseBooleanField_thenErrorResponse() throws Exception { |     void whenInvalidInputForFalseBooleanField_thenErrorResponse() throws Exception { | ||||||
| 
 |  | ||||||
|         String postBody = "{\"boolField\":true,\"trueField\":true,\"falseField\":true,\"boolStringVar\":\"+\"}"; |         String postBody = "{\"boolField\":true,\"trueField\":true,\"falseField\":true,\"boolStringVar\":\"+\"}"; | ||||||
| 
 | 
 | ||||||
|         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") |         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") | ||||||
| @ -75,7 +71,6 @@ class ValidationControllerUnitTest { | |||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void whenInvalidBooleanFromJson_thenErrorResponse() throws Exception { |     void whenInvalidBooleanFromJson_thenErrorResponse() throws Exception { | ||||||
| 
 |  | ||||||
|         String postBody = "{\"boolField\":true,\"trueField\":true,\"falseField\":false,\"boolStringVar\":\"plus\"}"; |         String postBody = "{\"boolField\":true,\"trueField\":true,\"falseField\":false,\"boolStringVar\":\"plus\"}"; | ||||||
| 
 | 
 | ||||||
|         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") |         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") | ||||||
| @ -85,12 +80,10 @@ class ValidationControllerUnitTest { | |||||||
|             .getContentAsString(); |             .getContentAsString(); | ||||||
| 
 | 
 | ||||||
|         assertEquals("Only values accepted as Boolean are + and -", output); |         assertEquals("Only values accepted as Boolean are + and -", output); | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void whenAllBooleanFieldsValid_thenCorrectResponse() throws Exception { |     void whenAllBooleanFieldsValid_thenCorrectResponse() throws Exception { | ||||||
| 
 |  | ||||||
|         String postBody = "{\"boolField\":true,\"trueField\":true,\"falseField\":false,\"boolStringVar\":\"+\"}"; |         String postBody = "{\"boolField\":true,\"trueField\":true,\"falseField\":false,\"boolStringVar\":\"+\"}"; | ||||||
| 
 | 
 | ||||||
|         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") |         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") | ||||||
| @ -100,30 +93,25 @@ class ValidationControllerUnitTest { | |||||||
|             .getContentAsString(); |             .getContentAsString(); | ||||||
| 
 | 
 | ||||||
|         assertEquals("BooleanObject is valid", output); |         assertEquals("BooleanObject is valid", output); | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void givenAllBooleanFieldsValid_whenServiceValidationFails_thenErrorResponse() throws Exception { |     void givenAllBooleanFieldsValid_whenServiceValidationFails_thenErrorResponse() throws Exception { | ||||||
| 
 |  | ||||||
|         mockMvc.perform(post("/validateBooleanAtService").contentType("application/json")) |         mockMvc.perform(post("/validateBooleanAtService").contentType("application/json")) | ||||||
|             .andExpect(status().isInternalServerError()); |             .andExpect(status().isInternalServerError()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void whenNullInputForTrueBooleanField_thenCorrectResponse() throws Exception { |     void whenNullInputForTrueBooleanField_thenCorrectResponse() throws Exception { | ||||||
| 
 |  | ||||||
|         String postBody = "{\"boolField\":true,\"trueField\":null,\"falseField\":false,\"boolStringVar\":\"+\"}"; |         String postBody = "{\"boolField\":true,\"trueField\":null,\"falseField\":false,\"boolStringVar\":\"+\"}"; | ||||||
| 
 | 
 | ||||||
|         mockMvc.perform(post("/validateBoolean").contentType("application/json") |         mockMvc.perform(post("/validateBoolean").contentType("application/json") | ||||||
|             .content(postBody)) |             .content(postBody)) | ||||||
|             .andExpect(status().isOk()); |             .andExpect(status().isOk()); | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void whenNullInputForFalseBooleanField_thenHttpBadRequestAsHttpResponse() throws Exception { |     void whenNullInputForFalseBooleanField_thenHttpBadRequestAsHttpResponse() throws Exception { | ||||||
| 
 |  | ||||||
|         String postBody = "{\"boolField\":true,\"trueField\":true,\"falseField\":null,\"boolStringVar\":\"+\"}"; |         String postBody = "{\"boolField\":true,\"trueField\":true,\"falseField\":null,\"boolStringVar\":\"+\"}"; | ||||||
| 
 | 
 | ||||||
|         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") |         String output = mockMvc.perform(post("/validateBoolean").contentType("application/json") | ||||||
| @ -133,6 +121,5 @@ class ValidationControllerUnitTest { | |||||||
|             .getContentAsString(); |             .getContentAsString(); | ||||||
| 
 | 
 | ||||||
|         assertEquals("falseField cannot be null", output); |         assertEquals("falseField cannot be null", output); | ||||||
| 
 |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -8,21 +8,14 @@ class BooleanUnitTest { | |||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void givenInputAsString_whenStringToBoolean_thenValidBooleanConversion() { |     void givenInputAsString_whenStringToBoolean_thenValidBooleanConversion() { | ||||||
|         Boolean trueVar = Boolean.valueOf("TRUE"); |         assertEquals(Boolean.TRUE, Boolean.valueOf("TRUE")); | ||||||
|         Boolean falseVar = Boolean.valueOf("false"); |         assertEquals(Boolean.FALSE, Boolean.valueOf("false")); | ||||||
|         Boolean parsedVar = Boolean.parseBoolean("True"); |         assertEquals(Boolean.TRUE, Boolean.parseBoolean("True")); | ||||||
| 
 |  | ||||||
|         assertEquals(Boolean.TRUE, trueVar); |  | ||||||
|         assertEquals(Boolean.FALSE, falseVar); |  | ||||||
|         assertEquals(Boolean.TRUE, parsedVar); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @Test |     @Test | ||||||
|     void givenInputAsboolean_whenbooleanToBoolean_thenValidBooleanConversion() { |     void givenInputAsboolean_whenbooleanToBoolean_thenValidBooleanConversion() { | ||||||
|         Boolean trueVar = Boolean.valueOf(true); |         assertEquals(Boolean.TRUE, Boolean.valueOf(true)); | ||||||
|         Boolean falseVar = Boolean.valueOf(false); |         assertEquals(Boolean.FALSE, Boolean.valueOf(false)); | ||||||
| 
 |  | ||||||
|         assertEquals(Boolean.TRUE, trueVar); |  | ||||||
|         assertEquals(Boolean.FALSE, falseVar); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user