ConsumesAnnotationHandler extends StringBasedAnnotationHandler<Consumes> { @Override public void handleMethodAnnotation(Consumes annotation, MethodConfigBuilder builder) { if(annotation.value().length >= 1) { builder.setProduces(ph(annotation.value()[0])); } } ConsumesAnnotationHandler(CRestConfig crestConfig); @Override void handleInterfaceAnnotation(Consumes annotation, InterfaceConfigBuilder builder); @Override void handleMethodAnnotation(Consumes annotation, MethodConfigBuilder builder);  }
@Test public void handleMethodAnnotationShouldFillProducesWithFirstAnnotationValue() throws Exception { when(mockAnnotation.value()).thenReturn(new String[]{"a","b"}); when(mockMethodConfigBuilder.setProduces("a")).thenReturn(mockMethodConfigBuilder); toTest.handleMethodAnnotation(mockAnnotation, mockMethodConfigBuilder); verify(mockAnnotation, times(2)).value(); verify(mockMethodConfigBuilder).setProduces("a"); }
@Test public void handleMethodAnnotationShouldMergePlaceholdersAndFillProducesWithFirstAnnotationValue() throws Exception { when(mockAnnotation.value()).thenReturn(new String[]{VAL_WITH_PH + "a", VAL_WITH_PH + "b"}); when(mockMethodConfigBuilder.setProduces(EXPECTED_MERGE_VAL + "a")).thenReturn(mockMethodConfigBuilder); toTest.handleMethodAnnotation(mockAnnotation, mockMethodConfigBuilder); verify(mockAnnotation, times(2)).value(); verify(mockMethodConfigBuilder).setProduces(EXPECTED_MERGE_VAL + "a"); }