Skip to content

Commit 2a6c3d4

Browse files
Update Service Layer Testing examples (#2458)
Updates the Service Layer Testing documentation examples to inject `CatalogService` directly instead of `CqnService`. The `@Qualifier` annotation is no longer required when using the typed service interface, making the examples simpler. Also, a duplicate catalogService.emit(context) call in the submitOrderExceedingStock example was removed.
1 parent 6015c0d commit 2a6c3d4

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

java/developing-applications/testing.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ To verify the proper discount application in our example, we can run a `Select`
148148
public class CatalogServiceTest {
149149

150150
@Autowired
151-
@Qualifier(CatalogService_.CDS_NAME)
152-
private CqnService catalogService;
151+
private CatalogService catalogService;
153152

154153
@Test
155154
public void discountApplied() {
@@ -172,8 +171,7 @@ Looking at the `onSubmitOrder` method from our example above we see that it uses
172171
public class CatalogServiceTest {
173172

174173
@Autowired
175-
@Qualifier(CatalogService_.CDS_NAME)
176-
private CqnService catalogService;
174+
private CatalogService catalogService;
177175

178176
@Test
179177
public void submitOrder() {
@@ -196,8 +194,7 @@ In the same way you can verify that the `ServiceException` is being thrown when
196194
public class CatalogServiceTest {
197195

198196
@Autowired
199-
@Qualifier(CatalogService_.CDS_NAME)
200-
private CqnService catalogService;
197+
private CatalogService catalogService;
201198

202199
@Test
203200
public void submitOrderExceedingStock() {
@@ -206,7 +203,6 @@ public class CatalogServiceTest {
206203
// ID of a book known to have a stock quantity of 22
207204
context.setBook("4a519e61-3c3a-4bd9-ab12-d7e0c5329933");
208205
context.setQuantity(30);
209-
catalogService.emit(context);
210206

211207
assertThrows(ServiceException.class, () -> catalogService.emit(context), context.getQuantity() + " exceeds stock for book");
212208
}

0 commit comments

Comments
 (0)