PathParamAnnotationHandler extends ParamAnnotationHandler<PathParam> { @Override public void handleMethodAnnotation(PathParam annotation, MethodConfigBuilder builder) { builder.startExtraParamConfig() .setType(PATH) .setName(ph(annotation.value())) .setDefaultValue(nullIfUnset(ph(annotation.defaultValue()))); } PathParamAnnotationHandler(CRestConfig crestConfig); @Override void handleInterfaceAnnotation(PathParam annotation, InterfaceConfigBuilder builder); @Override void handleMethodAnnotation(PathParam annotation, MethodConfigBuilder builder); @Override void handleParameterAnnotation(PathParam annotation, ParamConfigBuilder builder);  }
@Test public void handleMethodAnnotationShouldSetParamsTypeAndNameAndDefaultValue() throws Exception { when(mockMethodConfigBuilder.startExtraParamConfig()).thenReturn(mockParamConfigBuilder); when(mockParamConfigBuilder.setType(any(ParamType.class))).thenReturn(mockParamConfigBuilder); when(mockParamConfigBuilder.setName(any(String.class))).thenReturn(mockParamConfigBuilder); when(mockAnnotation.value()).thenReturn("a"); when(mockAnnotation.defaultValue()).thenReturn("b"); toTest.handleMethodAnnotation(mockAnnotation, mockMethodConfigBuilder); verify(mockMethodConfigBuilder).startExtraParamConfig(); verify(mockParamConfigBuilder).setType(ParamType.PATH); verify(mockParamConfigBuilder).setName("a"); verify(mockParamConfigBuilder).setDefaultValue("b"); verify(mockAnnotation).value(); verify(mockAnnotation).defaultValue(); }
@Test public void handleMethodAnnotationShouldSetParamsTypeAndName() throws Exception { when(mockMethodConfigBuilder.startExtraParamConfig()).thenReturn(mockParamConfigBuilder); when(mockParamConfigBuilder.setType(any(ParamType.class))).thenReturn(mockParamConfigBuilder); when(mockParamConfigBuilder.setName(any(String.class))).thenReturn(mockParamConfigBuilder); when(mockAnnotation.value()).thenReturn("a"); when(mockAnnotation.defaultValue()).thenReturn(""); toTest.handleMethodAnnotation(mockAnnotation, mockMethodConfigBuilder); verify(mockMethodConfigBuilder).startExtraParamConfig(); verify(mockParamConfigBuilder).setType(ParamType.PATH); verify(mockParamConfigBuilder).setName("a"); verify(mockParamConfigBuilder).setDefaultValue(null); verify(mockAnnotation).value(); verify(mockAnnotation).defaultValue(); }
@Test public void handleMethodAnnotationShouldMergePlaceholdersAndSetParamsTypeAndNameAndDefaultValue() throws Exception { when(mockMethodConfigBuilder.startExtraParamConfig()).thenReturn(mockParamConfigBuilder); when(mockParamConfigBuilder.setType(any(ParamType.class))).thenReturn(mockParamConfigBuilder); when(mockParamConfigBuilder.setName(any(String.class))).thenReturn(mockParamConfigBuilder); when(mockAnnotation.value()).thenReturn(VAL_WITH_PH + "a"); when(mockAnnotation.defaultValue()).thenReturn(VAL_WITH_PH + "b"); toTest.handleMethodAnnotation(mockAnnotation, mockMethodConfigBuilder); verify(mockMethodConfigBuilder).startExtraParamConfig(); verify(mockParamConfigBuilder).setType(ParamType.PATH); verify(mockParamConfigBuilder).setName(EXPECTED_MERGE_VAL + "a"); verify(mockParamConfigBuilder).setDefaultValue(EXPECTED_MERGE_VAL + "b"); verify(mockAnnotation).value(); verify(mockAnnotation).defaultValue(); }