-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33927 from mkouba/quarkuscomponenttest-alllist-su…
…pport QuarkusComponentTest - add support for `@All` List injection points
- Loading branch information
Showing
6 changed files
with
169 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...junit5-component/src/test/java/io/quarkus/test/component/declarative/ListAllMockTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.quarkus.test.component.declarative; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
|
||
import java.util.List; | ||
|
||
import jakarta.inject.Inject; | ||
import jakarta.inject.Singleton; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
|
||
import io.quarkus.arc.All; | ||
import io.quarkus.test.component.ConfigureMock; | ||
import io.quarkus.test.component.QuarkusComponentTest; | ||
import io.quarkus.test.component.beans.Bravo; | ||
import io.quarkus.test.component.beans.Delta; | ||
import io.quarkus.test.component.beans.SimpleQualifier; | ||
|
||
@QuarkusComponentTest | ||
public class ListAllMockTest { | ||
|
||
@Inject | ||
ListAllComponent component; | ||
|
||
@ConfigureMock | ||
Delta delta; | ||
|
||
@ConfigureMock | ||
@SimpleQualifier | ||
Bravo bravo; | ||
|
||
@Test | ||
public void testMock() { | ||
Mockito.when(delta.ping()).thenReturn(false); | ||
Mockito.when(bravo.ping()).thenReturn("ok"); | ||
assertFalse(component.ping()); | ||
assertEquals(1, component.bravos.size()); | ||
assertEquals("ok", component.bravos.get(0).ping()); | ||
} | ||
|
||
@Singleton | ||
static class ListAllComponent { | ||
|
||
@All | ||
List<Delta> deltas; | ||
|
||
@All | ||
@SimpleQualifier | ||
List<Bravo> bravos; | ||
|
||
boolean ping() { | ||
return deltas.get(0).ping(); | ||
} | ||
|
||
} | ||
} |