类javax.validation.UnexpectedTypeException源码实例Demo

下面列出了怎么用javax.validation.UnexpectedTypeException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: api-layer   文件: ApiTransformationConfig.java
@Bean
@Scope(value = "prototype")
public AbstractApiDocService abstractApiDocService(String content) {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    try {
        ObjectNode objectNode = mapper.readValue(content, ObjectNode.class);
        JsonNode openApiNode = objectNode.get("openapi");
        if (openApiNode != null) {
            return new ApiDocV3Service(gatewayClient);
        } else {
            JsonNode swaggerNode = objectNode.get("swagger");
            if (swaggerNode != null) {
                return new ApiDocV2Service(gatewayClient);
            }
        }
    } catch (IOException e) {
        log.debug("Could not convert response body to a Swagger/OpenAPI object.", e);
        throw new UnexpectedTypeException("Response is not a Swagger or OpenAPI type object.");
    }

    return null;
}
 
源代码2 项目: api-layer   文件: TransformApiDocService.java
/**
 * Does transformation API documentation
 *
 * @param serviceId  the unique service id
 * @param apiDocInfo the API doc and additional information about transformation
 * @return the transformed API documentation relative to Gateway
 * @throws ApiDocTransformationException if could not convert Swagger/OpenAPI to JSON
 * @throws UnexpectedTypeException       if response is not a Swagger/OpenAPI type object
 */
public String transformApiDoc(String serviceId, ApiDocInfo apiDocInfo) {
    //maybe null check of apidocinfo
    AbstractApiDocService abstractApiDocService = beanApiDocFactory.apply(apiDocInfo.getApiDocContent());
    if (abstractApiDocService == null) {
        throw new UnexpectedTypeException("Response is not a Swagger or OpenAPI type object.");
    }

    return abstractApiDocService.transformApiDoc(serviceId, apiDocInfo);
}
 
源代码3 项目: api-layer   文件: ApiDocV3Service.java
public String transformApiDoc(String serviceId, ApiDocInfo apiDocInfo) {
    SwaggerParseResult parseResult = new OpenAPIV3Parser().readContents(apiDocInfo.getApiDocContent());
    OpenAPI openAPI = parseResult.getOpenAPI();

    if (openAPI == null) {
        log.debug("Could not convert response body to an OpenAPI object for service {}. {}", serviceId, parseResult.getMessages());

        if (parseResult.getMessages() == null) {
            throw new UnexpectedTypeException("Response is not an OpenAPI type object.");
        } else {
            throw new UnexpectedTypeException(parseResult.getMessages().toString());
        }
    }

    boolean hidden = isHidden(openAPI.getTags());

    updatePaths(openAPI, serviceId, apiDocInfo, hidden);
    updateServerAndLink(openAPI, serviceId, hidden);
    updateExternalDoc(openAPI, apiDocInfo);

    try {
        return initializeObjectMapper().writeValueAsString(openAPI);
    } catch (JsonProcessingException e) {
        log.debug("Could not convert Swagger to JSON", e);
        throw new ApiDocTransformationException("Could not convert Swagger to JSON");
    }
}
 
源代码4 项目: api-layer   文件: ApiDocV2ServiceTest.java
@Test
public void givenSwaggerJsonNotAsExpectedFormat_whenConvertToSwagger_thenThrowIOException () throws IOException {
    String apiDocContent = "Failed content";

    ApiDocInfo apiDocInfo = new ApiDocInfo(null, apiDocContent, null);

    exceptionRule.expect(UnexpectedTypeException.class);
    exceptionRule.expectMessage("Response is not a Swagger type object.");

    apiDocV2Service.transformApiDoc(SERVICE_ID, apiDocInfo);
}
 
源代码5 项目: api-layer   文件: ApiTransformationConfigTest.java
@Test
public void testApiDocFactory_whenApDocVersionIsNotAsExpectedFormat() {
    exceptionRule.expect(UnexpectedTypeException.class);
    exceptionRule.expectMessage("Response is not a Swagger or OpenAPI type object");

    AbstractApiDocService abstractApiDocService = beanApiDocFactory.apply("FAILED FORMAT");
    assertNull(abstractApiDocService);
}
 
源代码6 项目: api-layer   文件: ApiDocV3ServiceTest.java
@Test
public void givenEmptyJson_whenApiDocTransform_thenThrowException() {
    String invalidJson = "";
    ApiInfo apiInfo = new ApiInfo("org.zowe.apicatalog", "api/v1", "3.0.0", "https://localhost:10014/apicatalog/api-doc", "https://www.zowe.org");
    ApiDocInfo apiDocInfo = new ApiDocInfo(apiInfo, invalidJson, null);

    exceptionRule.expect(UnexpectedTypeException.class);
    exceptionRule.expectMessage("No swagger supplied");
    apiDocV3Service.transformApiDoc(SERVICE_ID, apiDocInfo);
}
 
源代码7 项目: api-layer   文件: ApiDocV3ServiceTest.java
@Test
public void givenInvalidJson_whenApiDocTransform_thenThrowException() {
    String invalidJson = "nonsense";
    ApiInfo apiInfo = new ApiInfo("org.zowe.apicatalog", "api/v1", "3.0.0", "https://localhost:10014/apicatalog/api-doc", "https://www.zowe.org");
    ApiDocInfo apiDocInfo = new ApiDocInfo(apiInfo, invalidJson, null);

    exceptionRule.expect(UnexpectedTypeException.class);
    exceptionRule.expectMessage("attribute openapi is not of type `object`");
    apiDocV3Service.transformApiDoc(SERVICE_ID, apiDocInfo);
}
 
源代码8 项目: api-layer   文件: TransformApiDocServiceTest.java
@Test
public void testTransformApiDoc_whenThereIsNotApiDocMatch() {
    exceptionRule.expect(UnexpectedTypeException.class);
    exceptionRule.expectMessage("Response is not a Swagger or OpenAPI type object");

    ApiDocInfo apiDocInfo = new ApiDocInfo(null, "DOC4", null);
    transformApiDocService.transformApiDoc(SERVICE_ID, apiDocInfo);
}
 
源代码9 项目: kaif   文件: Article.java
public String getLinkHint() {
  if (isExternalLink()) {
    try {
      return new URL(link).getHost();
    } catch (MalformedURLException e) {
      //this should never happened because constructor protected with design contract.
      throw new UnexpectedTypeException("malformed url");
    }
  } else {
    return "/z/" + zone;
  }
}
 
源代码10 项目: sinavi-jfw   文件: AnnotationTargetTypeTest.java
@Test
public void shouldThrowUnexpectedTypeException() throws NoSuchMethodException, SecurityException {
    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    Constructor<AnnotationTargetTypeBean> constructor = AnnotationTargetTypeBean.class.getConstructor();
    EXECUTABLE_VALIDATOR.validateConstructorReturnValue(constructor, new AnnotationTargetTypeBean());
}
 
源代码11 项目: sinavi-jfw   文件: FixedGreaterThanEqualsToTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class FixedGreaterThanEqualsToTargetBean {

        @FixedGreaterThanEqualsTo("0.5")
        public Object value;
    }
    FixedGreaterThanEqualsToTargetBean target = new FixedGreaterThanEqualsToTargetBean();
    VALIDATOR.validate(target);
}
 
源代码12 项目: sinavi-jfw   文件: RegexTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class RegexTargetBean {

        @Regex("(ok|OK)")
        public Object value;
    }
    RegexTargetBean target = new RegexTargetBean();
    VALIDATOR.validate(target);
}
 
源代码13 项目: sinavi-jfw   文件: MinByteLengthTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class MinByteLengthTargetBean {

        @MinByteLength(100)
        public Object value;
    }
    MinByteLengthTargetBean target = new MinByteLengthTargetBean();
    VALIDATOR.validate(target);
}
 
源代码14 项目: sinavi-jfw   文件: FixedBeforeTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class FixedBeforeTargetBean {

        @FixedBefore("2013/07/05")
        public Object value;
    }
    FixedBeforeTargetBean target = new FixedBeforeTargetBean();
    VALIDATOR.validate(target);
}
 
源代码15 项目: sinavi-jfw   文件: DateFormatTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class DateFormatTargetBean {

        @DateFormat
        public Object value;
    }
    DateFormatTargetBean target = new DateFormatTargetBean();
    VALIDATOR.validate(target);
}
 
源代码16 项目: sinavi-jfw   文件: ASCIITest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class ASCIITargetBean {

        @ASCII
        public Object value;
    }
    ASCIITargetBean target = new ASCIITargetBean();
    VALIDATOR.validate(target);
}
 
源代码17 项目: sinavi-jfw   文件: AlphamericTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class AlphamericTargetBean {

        @Alphameric
        public Object value;
    }
    AlphamericTargetBean target = new AlphamericTargetBean();
    VALIDATOR.validate(target);
}
 
源代码18 项目: sinavi-jfw   文件: MaxLengthTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class MaxLengthTargetBean {

        @MaxLength(5)
        public Object value;
    }
    MaxLengthTargetBean target = new MaxLengthTargetBean();
    VALIDATOR.validate(target);
}
 
源代码19 项目: sinavi-jfw   文件: FixedAfterTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class FixedAfterTargetBean {

        @FixedAfter("2013/07/04")
        public Object value;
    }
    FixedAfterTargetBean target = new FixedAfterTargetBean();
    VALIDATOR.validate(target);
}
 
源代码20 项目: sinavi-jfw   文件: FixedLessThanTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class FixedLessThanTargetBean {

        @FixedLessThan("0.5")
        public Object value;
    }
    FixedLessThanTargetBean target = new FixedLessThanTargetBean();
    VALIDATOR.validate(target);
}
 
源代码21 项目: sinavi-jfw   文件: EmailTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class EmailTargetBean {

        @Email
        public Object value;
    }
    EmailTargetBean target = new EmailTargetBean();
    VALIDATOR.validate(target);
}
 
源代码22 项目: sinavi-jfw   文件: CreditCardTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class CreditCardTargetBean {

        @CreditCard(value = Type.VISA)
        public Object value;
    }
    CreditCardTargetBean target = new CreditCardTargetBean();
    VALIDATOR.validate(target);
}
 
源代码23 项目: sinavi-jfw   文件: NumberTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class NumberTargetBean {

        @Number(precision = 2)
        public Object value;
    }
    NumberTargetBean target = new NumberTargetBean();
    VALIDATOR.validate(target);
}
 
源代码24 项目: sinavi-jfw   文件: MaxSizeTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class MaxSizeTargetBean {

        @MaxSize(5)
        public Object value;
    }
    MaxSizeTargetBean target = new MaxSizeTargetBean();
    VALIDATOR.validate(target);
}
 
源代码25 项目: sinavi-jfw   文件: AlphabetTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class AlphabetTargetBean {

        @Alphabet
        public Object value;
    }
    AlphabetTargetBean target = new AlphabetTargetBean();
    VALIDATOR.validate(target);
}
 
源代码26 项目: sinavi-jfw   文件: FixedAfterEqualsToTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class FixedAfterEqualsToTargetBean {

        @FixedAfterEqualsTo("2013/07/04")
        public Object value;
    }
    FixedAfterEqualsToTargetBean target = new FixedAfterEqualsToTargetBean();
    VALIDATOR.validate(target);
}
 
源代码27 项目: sinavi-jfw   文件: FixedGreaterThanTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class FixedGreaterThanTargetBean {

        @FixedGreaterThan("0.5")
        public Object value;
    }
    FixedGreaterThanTargetBean target = new FixedGreaterThanTargetBean();
    VALIDATOR.validate(target);
}
 
源代码28 项目: sinavi-jfw   文件: ZenkakuTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class ZenkakuTargetBean {

        @Zenkaku
        public Object value;
    }
    ZenkakuTargetBean target = new ZenkakuTargetBean();
    VALIDATOR.validate(target);
}
 
源代码29 项目: sinavi-jfw   文件: FixedBeforeEqualsToTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class FixedBeforeEqualsToTargetBean {

        @FixedBeforeEqualsTo("2013/07/05")
        public Object value;
    }
    FixedBeforeEqualsToTargetBean target = new FixedBeforeEqualsToTargetBean();
    VALIDATOR.validate(target);
}
 
源代码30 项目: sinavi-jfw   文件: MaxByteLengthTest.java
@Test
public void shouldThrowUnexpectedTypeException() {

    thrown.expect(UnexpectedTypeException.class);
    thrown.expectMessage(containsString("HV000030"));
    class MaxByteLengthTargetBean {

        @MaxByteLength(100)
        public Object value;
    }
    MaxByteLengthTargetBean target = new MaxByteLengthTargetBean();
    VALIDATOR.validate(target);
}
 
 类所在包
 同包方法