@@ -764,6 +764,38 @@ void testAddingTemplatedParameterWithTheSameKey() throws NoSuchMethodException {
764764 assertThat (data .template ().headers ().get ("Accept" )).contains ("application/json" , "{Accept}" );
765765 }
766766
767+ @ Test
768+ void testMultipleProducesValues () throws NoSuchMethodException {
769+ Method method = TestTemplate_MultipleProduces .class .getDeclaredMethod ("multipleProduces" );
770+ MethodMetadata data = contract .parseAndValidateMetadata (method .getDeclaringClass (), method );
771+
772+ assertThat (data .template ().headers ().get ("Accept" )).containsExactly ("application/jose" , "application/json" );
773+ }
774+
775+ @ Test
776+ void testSingleProducesValueUnchanged () throws NoSuchMethodException {
777+ Method method = TestTemplate_MultipleProduces .class .getDeclaredMethod ("singleProduces" );
778+ MethodMetadata data = contract .parseAndValidateMetadata (method .getDeclaringClass (), method );
779+
780+ assertThat (data .template ().headers ().get ("Accept" )).containsExactly (MediaType .APPLICATION_JSON_VALUE );
781+ }
782+
783+ @ Test
784+ void testEmptyProducesNoAcceptHeader () throws NoSuchMethodException {
785+ Method method = TestTemplate_MultipleProduces .class .getDeclaredMethod ("noProduces" );
786+ MethodMetadata data = contract .parseAndValidateMetadata (method .getDeclaringClass (), method );
787+
788+ assertThat (data .template ().headers ().get ("Accept" )).isNull ();
789+ }
790+
791+ @ Test
792+ void testProducesWithBlankEntryIgnored () throws NoSuchMethodException {
793+ Method method = TestTemplate_MultipleProduces .class .getDeclaredMethod ("producesWithBlankEntry" );
794+ MethodMetadata data = contract .parseAndValidateMetadata (method .getDeclaringClass (), method );
795+
796+ assertThat (data .template ().headers ().get ("Accept" )).containsExactly ("application/jose" , "application/json" );
797+ }
798+
767799 @ Test
768800 void testMultipleRequestPartAnnotations () throws NoSuchMethodException {
769801 Method method = TestTemplate_RequestPart .class .getDeclaredMethod ("requestWithMultipleParts" ,
@@ -1141,4 +1173,20 @@ public String toString() {
11411173
11421174 }
11431175
1176+ public interface TestTemplate_MultipleProduces {
1177+
1178+ @ GetMapping (value = "/test" , produces = { "application/jose" , "application/json" })
1179+ ResponseEntity <TestObject > multipleProduces ();
1180+
1181+ @ GetMapping (value = "/test" , produces = MediaType .APPLICATION_JSON_VALUE )
1182+ ResponseEntity <TestObject > singleProduces ();
1183+
1184+ @ GetMapping ("/test" )
1185+ ResponseEntity <TestObject > noProduces ();
1186+
1187+ @ GetMapping (value = "/test" , produces = { "application/jose" , "" , "application/json" })
1188+ ResponseEntity <TestObject > producesWithBlankEntry ();
1189+
1190+ }
1191+
11441192}
0 commit comments