From c8c35eb60a53bc19109705bfa4d49f36bf7860ac Mon Sep 17 00:00:00 2001 From: Juan Brasca Date: Wed, 4 Mar 2020 13:08:34 -0300 Subject: [PATCH] Add test to reproduce the issue --- .../raml/v2/api/ResourceTypeTraitIssue.java | 51 +++++++++++++++++++ .../test/resources/org/raml/v2/issue/api.raml | 25 +++++++++ 2 files changed, 76 insertions(+) create mode 100644 raml-parser-2/src/test/java/org/raml/v2/api/ResourceTypeTraitIssue.java create mode 100644 raml-parser-2/src/test/resources/org/raml/v2/issue/api.raml diff --git a/raml-parser-2/src/test/java/org/raml/v2/api/ResourceTypeTraitIssue.java b/raml-parser-2/src/test/java/org/raml/v2/api/ResourceTypeTraitIssue.java new file mode 100644 index 00000000..966b96f7 --- /dev/null +++ b/raml-parser-2/src/test/java/org/raml/v2/api/ResourceTypeTraitIssue.java @@ -0,0 +1,51 @@ +/* + * Copyright 2013 (c) MuleSoft, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + */ +package org.raml.v2.api; + +import org.junit.Test; +import org.raml.v2.api.model.v10.api.Api; +import org.raml.v2.api.model.v10.datamodel.IntegerTypeDeclaration; +import org.raml.v2.api.model.v10.datamodel.ObjectTypeDeclaration; +import org.raml.v2.api.model.v10.datamodel.TypeDeclaration; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +public class ResourceTypeTraitIssue +{ + + @Test + public void testApi() throws IOException + { + File input = new File("src/test/resources/org/raml/v2/issue/api.raml"); + assertTrue(input.isFile()); + RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(input); + assertFalse(ramlModelResult.hasErrors()); + Api api = ramlModelResult.getApiV10(); + + assertEquals(2, api.resources().get(0).methods().get(0).queryParameters().size()); + } + + +} diff --git a/raml-parser-2/src/test/resources/org/raml/v2/issue/api.raml b/raml-parser-2/src/test/resources/org/raml/v2/issue/api.raml new file mode 100644 index 00000000..58fdca9b --- /dev/null +++ b/raml-parser-2/src/test/resources/org/raml/v2/issue/api.raml @@ -0,0 +1,25 @@ +#%RAML 1.0 +title: test-date-spec +version: v1 +baseUri: http://localhost:8081 + +resourceTypes: + read: + get: + +traits: + sercheable: + usage: Apply this trait to resources which supports datetime range searching + queryParameters: + dateFrom: + type: date-only + example: "2017-10-02" + required: false + dateTo: + type: date-only + example: "2018-10-02" + required: false + +/testuri: + is: [sercheable] + type: read