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