This is an automated email from the ASF dual-hosted git repository.

aldettinger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e7862d  Completed bean itests with an @InjectMock test
3e7862d is described below

commit 3e7862d2846ebc1326d724258781815442ac9e80
Author: aldettinger <aldettin...@gmail.com>
AuthorDate: Wed Aug 5 15:05:23 2020 +0200

    Completed bean itests with an @InjectMock test
---
 integration-tests/bean/pom.xml                     |  5 ++
 .../quarkus/component/bean/BeanInjectMockTest.java | 59 ++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/integration-tests/bean/pom.xml b/integration-tests/bean/pom.xml
index 1ead13d..6a38fbc 100644
--- a/integration-tests/bean/pom.xml
+++ b/integration-tests/bean/pom.xml
@@ -65,6 +65,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-junit5-mockito</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>io.rest-assured</groupId>
             <artifactId>rest-assured</artifactId>
             <scope>test</scope>
diff --git 
a/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanInjectMockTest.java
 
b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanInjectMockTest.java
new file mode 100644
index 0000000..124c9fc
--- /dev/null
+++ 
b/integration-tests/bean/src/test/java/org/apache/camel/quarkus/component/bean/BeanInjectMockTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.bean;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.quarkus.test.junit.mockito.InjectMock;
+import io.restassured.RestAssured;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.Matchers.is;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.Mockito.when;
+
+@QuarkusTest
+public class BeanInjectMockTest {
+
+    @InjectMock
+    NamedBean mockNamedBean;
+
+    @BeforeEach
+    public void setup() {
+        when(mockNamedBean.hello(anyString())).thenReturn("Hello * from 
NamedBean mock (class level)");
+    }
+
+    @Test
+    public void namedBeanMockedForAllTests() {
+        RestAssured.given()
+                .body("Kermit")
+                .post("/bean/named")
+                .then()
+                .body(is("Hello * from NamedBean mock (class level)"));
+    }
+
+    @Test
+    public void namedBeanMockOverrriddenInATest() {
+        when(mockNamedBean.hello(anyString())).thenReturn("Hello * from 
NamedBean mock (test level)");
+        RestAssured.given()
+                .body("Kermit")
+                .post("/bean/named")
+                .then()
+                .body(is("Hello * from NamedBean mock (test level)"));
+    }
+
+}

Reply via email to