@@ -780,6 +780,38 @@ void testAddingTemplatedParameterWithTheSameKey() throws NoSuchMethodException {
780780 assertThat (data .template ().headers ().get ("Accept" )).contains ("application/json" , "{Accept}" );
781781 }
782782
783+ @ Test
784+ void testMultipleProducesValues () throws NoSuchMethodException {
785+ Method method = TestTemplate_MultipleProduces .class .getDeclaredMethod ("multipleProduces" );
786+ MethodMetadata data = contract .parseAndValidateMetadata (method .getDeclaringClass (), method );
787+
788+ assertThat (data .template ().headers ().get ("Accept" )).containsExactly ("application/jose" , "application/json" );
789+ }
790+
791+ @ Test
792+ void testSingleProducesValueUnchanged () throws NoSuchMethodException {
793+ Method method = TestTemplate_MultipleProduces .class .getDeclaredMethod ("singleProduces" );
794+ MethodMetadata data = contract .parseAndValidateMetadata (method .getDeclaringClass (), method );
795+
796+ assertThat (data .template ().headers ().get ("Accept" )).containsExactly (MediaType .APPLICATION_JSON_VALUE );
797+ }
798+
799+ @ Test
800+ void testEmptyProducesNoAcceptHeader () throws NoSuchMethodException {
801+ Method method = TestTemplate_MultipleProduces .class .getDeclaredMethod ("noProduces" );
802+ MethodMetadata data = contract .parseAndValidateMetadata (method .getDeclaringClass (), method );
803+
804+ assertThat (data .template ().headers ().get ("Accept" )).isNull ();
805+ }
806+
807+ @ Test
808+ void testProducesWithBlankEntryIgnored () throws NoSuchMethodException {
809+ Method method = TestTemplate_MultipleProduces .class .getDeclaredMethod ("producesWithBlankEntry" );
810+ MethodMetadata data = contract .parseAndValidateMetadata (method .getDeclaringClass (), method );
811+
812+ assertThat (data .template ().headers ().get ("Accept" )).containsExactly ("application/jose" , "application/json" );
813+ }
814+
783815 @ Test
784816 void testMultipleRequestPartAnnotations () throws NoSuchMethodException {
785817 Method method = TestTemplate_RequestPart .class .getDeclaredMethod ("requestWithMultipleParts" ,
@@ -1160,4 +1192,20 @@ public String toString() {
11601192
11611193 }
11621194
1195+ public interface TestTemplate_MultipleProduces {
1196+
1197+ @ GetMapping (value = "/test" , produces = { "application/jose" , "application/json" })
1198+ ResponseEntity <TestObject > multipleProduces ();
1199+
1200+ @ GetMapping (value = "/test" , produces = MediaType .APPLICATION_JSON_VALUE )
1201+ ResponseEntity <TestObject > singleProduces ();
1202+
1203+ @ GetMapping ("/test" )
1204+ ResponseEntity <TestObject > noProduces ();
1205+
1206+ @ GetMapping (value = "/test" , produces = { "application/jose" , "" , "application/json" })
1207+ ResponseEntity <TestObject > producesWithBlankEntry ();
1208+
1209+ }
1210+
11631211}
0 commit comments