ppalaga commented on a change in pull request #2525: URL: https://github.com/apache/camel-quarkus/pull/2525#discussion_r622337826
########## File path: integration-tests/mybatis/src/test/java/org/apache/camel/quarkus/component/mybatis/it/MyBatisTest.java ########## @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.apache.camel.quarkus.component.mybatis.it; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.h2.H2DatabaseTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.apache.camel.quarkus.component.mybatis.it.entity.Account; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.Matchers.equalTo; + +@QuarkusTest +@QuarkusTestResource(H2DatabaseTestResource.class) +public class MyBatisTest { + + @Test + public void loadComponentMybatis() { + /* A simple autogenerated test */ + RestAssured.get("/mybatis/load/component/mybatis") + .then() + .statusCode(200); + } + + @Test + public void loadComponentMybatisBean() { + /* A simple autogenerated test */ + RestAssured.get("/mybatis/load/component/mybatis-bean") + .then() + .statusCode(200); + } + + @Test + public void testSelectOne() { + RestAssured.get("/mybatis/selectOne?id=456") + .then() + .statusCode(200) + .body("id", equalTo(456)) + .body("firstName", equalTo("Claus")) + .body("lastName", equalTo("Ibsen")) + .body("emailAddress", equalTo("non...@gmail.com")); + } + + @Test + public void testSelectOneNotFound() { + RestAssured.get("/mybatis/selectOne?id=999") + .then() + .statusCode(404); + } + + @Test + public void testInsert() { + Account account = new Account(); + account.setId(444); + account.setFirstName("Willem"); + account.setLastName("Jiang"); + account.setEmailAddress("fara...@gmail.com"); + + RestAssured.given() + .contentType(ContentType.JSON) + .body(account) + .post("/mybatis/insertOne") + .then() + .statusCode(200) + .body(equalTo("3")); + } + + @Test + public void testDelete() { + RestAssured.delete("/mybatis/deleteOne?id=456") + .then() + .statusCode(200) + .body(equalTo("1")); Review comment: I have not noticed that, thanks for the explanation. However, to ensure that the persistence layer really works, I think it would be better to test with a non-rollback transaction manager and always do a followup read call to ensure that the insert/update/delete was successful. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org