FormParamAnnotationHandler extends ParamAnnotationHandler<FormParam> { @Override public void handleParameterAnnotation(FormParam annotation, ParamConfigBuilder builder) { builder.setType(FORM) .setName(ph(annotation.value())) .setDefaultValue(nullIfUnset(ph(annotation.defaultValue()))); } FormParamAnnotationHandler(CRestConfig crestConfig); @Override void handleInterfaceAnnotation(FormParam annotation, InterfaceConfigBuilder builder); @Override void handleMethodAnnotation(FormParam annotation, MethodConfigBuilder builder); @Override void handleParameterAnnotation(FormParam annotation, ParamConfigBuilder builder);  }
@Test public void handleParameterAnnotationShouldSetTypeAndNameAndDefaultValue() throws Exception { when(super.mockParamConfigBuilder.setType(any(ParamType.class))).thenReturn(super.mockParamConfigBuilder); when(super.mockParamConfigBuilder.setName(any(String.class))).thenReturn(super.mockParamConfigBuilder); when(super.mockParamConfigBuilder.setDefaultValue(anyString())).thenReturn(super.mockParamConfigBuilder); when(mockAnnotation.value()).thenReturn("a"); when(mockAnnotation.defaultValue()).thenReturn("b"); toTest.handleParameterAnnotation(mockAnnotation, super.mockParamConfigBuilder); verify(super.mockParamConfigBuilder).setType(ParamType.FORM); verify(super.mockParamConfigBuilder).setName("a"); verify(super.mockParamConfigBuilder).setDefaultValue("b"); verify(mockAnnotation).value(); verify(mockAnnotation).defaultValue(); }
@Test public void handleParameterAnnotationShouldSetTypeAndName() throws Exception { when(super.mockParamConfigBuilder.setType(any(ParamType.class))).thenReturn(super.mockParamConfigBuilder); when(super.mockParamConfigBuilder.setName(any(String.class))).thenReturn(super.mockParamConfigBuilder); when(super.mockParamConfigBuilder.setDefaultValue(anyString())).thenReturn(super.mockParamConfigBuilder); when(mockAnnotation.value()).thenReturn("a"); when(mockAnnotation.defaultValue()).thenReturn(""); toTest.handleParameterAnnotation(mockAnnotation, super.mockParamConfigBuilder); verify(super.mockParamConfigBuilder).setType(ParamType.FORM); verify(super.mockParamConfigBuilder).setName("a"); verify(super.mockParamConfigBuilder).setDefaultValue(null); verify(mockAnnotation).value(); verify(mockAnnotation).defaultValue(); }
@Test public void handleParameterAnnotationShouldMergePlaceholdersAndSetTypeAndNameAndDefaultValue() throws Exception { when(super.mockParamConfigBuilder.setType(any(ParamType.class))).thenReturn(super.mockParamConfigBuilder); when(super.mockParamConfigBuilder.setName(any(String.class))).thenReturn(super.mockParamConfigBuilder); when(super.mockParamConfigBuilder.setDefaultValue(anyString())).thenReturn(super.mockParamConfigBuilder); when(mockAnnotation.value()).thenReturn(VAL_WITH_PH + "a"); when(mockAnnotation.defaultValue()).thenReturn(VAL_WITH_PH + "b"); toTest.handleParameterAnnotation(mockAnnotation, super.mockParamConfigBuilder); verify(super.mockParamConfigBuilder).setType(ParamType.FORM); verify(super.mockParamConfigBuilder).setName(EXPECTED_MERGE_VAL + "a"); verify(super.mockParamConfigBuilder).setDefaultValue(EXPECTED_MERGE_VAL + "b"); verify(mockAnnotation).value(); verify(mockAnnotation).defaultValue(); }