Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test apps with no paths #625

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.eclipse.microprofile.openapi.reader;

import java.util.HashMap;

import org.eclipse.microprofile.openapi.OASFactory;
import org.eclipse.microprofile.openapi.OASModelReader;
import org.eclipse.microprofile.openapi.models.Components;
import org.eclipse.microprofile.openapi.models.OpenAPI;
import org.eclipse.microprofile.openapi.models.info.Contact;
import org.eclipse.microprofile.openapi.models.info.Info;
import org.eclipse.microprofile.openapi.models.media.Schema;

public class MyOASModelReaderForJustComponentApp implements OASModelReader {

@Override
public OpenAPI buildModel() {
return OASFactory.createObject(OpenAPI.class)
.info(OASFactory.createObject(Info.class)
.title("MarketApp API")
.version("1.0")
.termsOfService("http://example.com/terms")
.contact(OASFactory.createObject(Contact.class)
.name("market API Support")
.url("http://example.com/contact")
.email("admin@example.com")))
.components(OASFactory.createObject(Components.class)
.schemas(new HashMap<String, Schema>())
.addSchema("id", OASFactory.createObject(Schema.class)
.addType(Schema.SchemaType.INTEGER)
.format("int32")));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.eclipse.microprofile.openapi.reader;

import org.eclipse.microprofile.openapi.OASFactory;
import org.eclipse.microprofile.openapi.OASModelReader;
import org.eclipse.microprofile.openapi.models.OpenAPI;
import org.eclipse.microprofile.openapi.models.info.Contact;
import org.eclipse.microprofile.openapi.models.info.Info;

public class MyOASModelReaderForJustWebHookApp implements OASModelReader {

@Override
public OpenAPI buildModel() {
return OASFactory.createObject(OpenAPI.class)
.info(OASFactory.createObject(Info.class)
.title("MarketApp API")
.version("1.0")
.termsOfService("http://example.com/terms")
.contact(OASFactory.createObject(Contact.class)
.name("market API Support")
.url("http://example.com/contact")
.email("admin@example.com")))
.addWebhook("MarketEvent", OASFactory.createPathItem()
.GET(OASFactory.createOperation()
.summary("Notifies that a deal has been done")
.responses(OASFactory.createAPIResponses()
.addAPIResponse("202", OASFactory.createAPIResponse()
.description(
"Indicates that the deal was processed successfully")))));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.eclipse.microprofile.openapi.tck;

import static org.hamcrest.Matchers.equalTo;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.annotations.Test;

import io.restassured.response.ValidatableResponse;

public class ModelReaderAppWithJustComponentTest extends AppTestBase {
@Deployment(name = "airlinesModelReader", testable = false)
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class, "noPathsAppReader.war")
.addPackages(true, "org.eclipse.microprofile.openapi.reader")
.addAsManifestResource("microprofile-reader-just-component.properties",
"microprofile-config.properties");
Comment on lines +33 to +34
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually putting the properties file in the wrong place, but the existing tests are also wrong, so I'll raise a new issue for that.

}

@Test(dataProvider = "formatProvider")
public void testDocumentCreated(String type) {
ValidatableResponse vr = callEndpoint(type);
vr.body("components.schemas.id.format", equalTo("int32"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.eclipse.microprofile.openapi.tck;

import static org.hamcrest.Matchers.equalTo;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.annotations.Test;

import io.restassured.response.ValidatableResponse;

public class ModelReaderAppWithJustWebHookTest extends AppTestBase {
@Deployment(name = "airlinesModelReader", testable = false)
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class, "noPathsAppReader.war")
.addPackages(true, "org.eclipse.microprofile.openapi.reader")
.addAsManifestResource("microprofile-reader-just-webhook.properties", "microprofile-config.properties");
}

@Test(dataProvider = "formatProvider")
public void testDocumentCreated(String type) {
ValidatableResponse vr = callEndpoint(type);
vr.body("webhooks.MarketEvent.get.summary", equalTo("Notifies that a deal has been done"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2024 Contributors to the Eclipse Foundation
# <p>
# 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
# <p>
# http://www.apache.org/licenses/LICENSE-2.0
# <p>
# 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.
mp.openapi.model.reader=org.eclipse.microprofile.openapi.reader.MyOASModelReaderForJustComponentApp
14 changes: 14 additions & 0 deletions tck/src/main/resources/microprofile-reader-just-webhook.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2024 Contributors to the Eclipse Foundation
# <p>
# 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
# <p>
# http://www.apache.org/licenses/LICENSE-2.0
# <p>
# 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.
mp.openapi.model.reader=org.eclipse.microprofile.openapi.reader.MyOASModelReaderForJustWebHookApp
Loading