Skip to content

Commit fcf2f8d

Browse files
committed
Minor refactoring in acceptance criteria
1 parent a3bfbab commit fcf2f8d

File tree

3 files changed

+2
-125
lines changed

3 files changed

+2
-125
lines changed

examples/spring-boot-demo/implementation/src/test/java/com/example/demo/acceptance/FilmQueryAcceptanceIT.java

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
3939
@Testcontainers
4040
@ActiveProfiles("test")
41-
@Sql("/init-sakila-test.sql")
41+
//@Sql("/init-sakila-test.sql")
4242
class FilmQueryAcceptanceIT {
4343

4444
@LocalServerPort
@@ -52,7 +52,7 @@ class FilmQueryAcceptanceIT {
5252
* Declared as compatible substitute for standard PostgreSQL container
5353
*/
5454
private static final DockerImageName SAKILA_POSTGRES_IMAGE = DockerImageName
55-
.parse("sakiladb/postgres:latest")
55+
.parse("frantiseks/postgres-sakila:latest")
5656
.asCompatibleSubstituteFor("postgres");
5757

5858
/**
@@ -282,82 +282,6 @@ void shouldHandleEmptyResultsGracefully() {
282282
assertThat(responseBody.get("filter")).isInstanceOf(Map.class);
283283
}
284284

285-
/**
286-
* Task 2.7: Create acceptance test for "Query films by different starting letters" scenario (parameterized)
287-
*
288-
* This test implements the Gherkin scenario outline:
289-
*
290-
* Scenario Outline: Query films by different starting letters
291-
* Given the film database contains movies with various titles
292-
* When I request films that start with the letter "<letter>"
293-
* Then I should receive a list of films with titles beginning with "<letter>"
294-
* And all returned film titles should start with the letter "<letter>"
295-
*
296-
* Examples:
297-
* | letter | expected_count |
298-
* | A | 46 |
299-
* | B | 54 |
300-
* | C | 58 |
301-
*
302-
* Tests multiple starting letters with parameterized approach.
303-
*/
304-
@ParameterizedTest
305-
@CsvSource({
306-
"A, 46",
307-
"B, 54",
308-
"C, 58"
309-
})
310-
void shouldQueryFilmsByDifferentStartingLetters(String letter, int expectedCount) {
311-
// Given: the film database contains movies with various titles (Sakila test data)
312-
// (Container setup provides the Sakila database with pre-loaded data)
313-
314-
// When: I request films that start with the specified letter
315-
String url = "/api/v1/films?startsWith=" + letter;
316-
ResponseEntity<Map> response = restTemplate.getForEntity(url, Map.class);
317-
318-
// Then: I should receive a HTTP 200 OK response
319-
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
320-
321-
// And: the response should be in JSON format
322-
assertThat(response.getHeaders().getContentType().toString())
323-
.contains("application/json");
324-
325-
// And: the response should contain the expected structure
326-
Map<String, Object> responseBody = response.getBody();
327-
assertThat(responseBody).isNotNull();
328-
assertThat(responseBody).containsKey("films");
329-
assertThat(responseBody).containsKey("count");
330-
assertThat(responseBody).containsKey("filter");
331-
332-
// And: I should receive a list of films with the expected count
333-
List<Map<String, Object>> films = (List<Map<String, Object>>) responseBody.get("films");
334-
assertThat(films).hasSize(expectedCount);
335-
336-
// And: the count field should match the number of films
337-
Integer count = (Integer) responseBody.get("count");
338-
assertThat(count).isEqualTo(expectedCount);
339-
340-
// And: the filter field should indicate the applied filter
341-
Map<String, Object> filter = (Map<String, Object>) responseBody.get("filter");
342-
assertThat(filter).containsEntry("startsWith", letter);
343-
344-
// And: all returned film titles should start with the specified letter
345-
films.forEach(film -> {
346-
String title = (String) film.get("title");
347-
assertThat(title)
348-
.as("Film title '%s' should start with letter '%s'", title, letter)
349-
.startsWithIgnoringCase(letter);
350-
});
351-
352-
// And: each film should have the required fields
353-
films.forEach(film -> {
354-
assertThat(film).containsKey("film_id");
355-
assertThat(film).containsKey("title");
356-
assertThat(film.get("film_id")).isNotNull();
357-
assertThat(film.get("title")).isNotNull();
358-
});
359-
}
360-
361285
/**
362286
* Task 2.8: Create acceptance test for "Invalid query parameter handling" scenario (HTTP 400)
363287
*

examples/spring-boot-demo/implementation/src/test/resources/init-sakila-test.sql

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,6 @@ INSERT INTO film (title) VALUES
2626
('ATTACKS HATE'), ('ATTRACTION NEWTON'), ('AUTUMN CROW'), ('AVIATOR POLLOCK'),
2727
('AWAKENINGS BED'), ('AWESOME GUMP');
2828

29-
-- Insert test data for films starting with 'B' (54 films expected)
30-
INSERT INTO film (title) VALUES
31-
('BABE GOLDFINGER'), ('BABYLON DIARY'), ('BACKLASH UNDEFEATED'), ('BADMAN DAWN'),
32-
('BAG CALMNESS'), ('BALLOON HOMEWARD'), ('BALLROOM MOCKINGBIRD'), ('BANGBANG CITIZEN'),
33-
('BARBARELLA STREETCAR'), ('BAREFOOT CHOCOLAT'), ('BASIC EASY'), ('BEACH HEARTBREAKERS'),
34-
('BEAN LOVELY'), ('BEAR GRACELAND'), ('BEAST HUNCHBACK'), ('BEAUTY GREASE'),
35-
('BED HIGHBALL'), ('BEDAZZLED MARRIED'), ('BEDKNOBS PERSPECTIVE'), ('BEETHOVEN EXORCIST'),
36-
('BEHOLDER SEAGAL'), ('BELOVED CHOCOLAT'), ('BENEATH RUSH'), ('BERETS AGENT'),
37-
('BEST WORST'), ('BEVERLY OUTLAW'), ('BICYCLE CREDIT'), ('BILL OTHERS'),
38-
('BINGO TALENTED'), ('BIRCH ANTITRUST'), ('BIRD INDEPENDENCE'), ('BIRDCAGE CASPER'),
39-
('BIRDS PERDITION'), ('BLACKOUT PRIVATE'), ('BLADE POLISH'), ('BLANKET BEVERLY'),
40-
('BLINDNESS GUN'), ('BLOOD ARGONAUTS'), ('BLUES INSTINCT'), ('BOARDED DARES'),
41-
('BOAT BANK'), ('BODIES DISOBEDIENCE'), ('BONNIE HOLOCAUST'), ('BOOGIE AMELIE'),
42-
('BOONDOCK BALLROOM'), ('BORN SPINAL'), ('BORROWERS BEDAZZLED'), ('BOULEVARD MOB'),
43-
('BOUND CHEAPER'), ('BOXER CLIMAX'), ('BRANNIGAN SUNRISE'), ('BRAVEHEART HUMAN'),
44-
('BREAD DAISY'), ('BREAKING HOME');
45-
46-
-- Insert test data for films starting with 'C' (58 films expected)
47-
INSERT INTO film (title) VALUES
48-
('CABIN FLASH'), ('CADDYSHACK JEDI'), ('CALENDAR GUNFIGHT'), ('CALIFORNIA BIRDS'),
49-
('CAMELOT VACATION'), ('CAMPUS REMEMBER'), ('CANDIDATE PERDITION'), ('CANDLES GRAPES'),
50-
('CANYON STOCK'), ('CAPER MOTIONS'), ('CAPTAIN FLYBOYS'), ('CARRIE BUNCH'),
51-
('CASABLANCA SUPER'), ('CASE NIGHTMARE'), ('CASSIDY WYOMING'), ('CASUALTIES ENCINO'),
52-
('CAT CONEHEADS'), ('CATCH ALADDIN'), ('CATWOMAN COMA'), ('CAUSE DATE'),
53-
('CELEBRITY HORN'), ('CENTER DINOSAUR'), ('CHAINSAW UPTOWN'), ('CHAMBER ITALIAN'),
54-
('CHAMPION FLATLINERS'), ('CHANCE RESURRECTION'), ('CHAPLIN LICENSE'), ('CHARADE DUFFEL'),
55-
('CHARIOTS CONSPIRACY'), ('CHASING FIGHT'), ('CHEAPEST HUNG'), ('CHICAGO NORTH'),
56-
('CHICKEN HELLFIGHTERS'), ('CHILL LUCK'), ('CHINATOWN GLADIATOR'), ('CHISUM BEHAVIOR'),
57-
('CHITTY LOCK'), ('CHOCOLAT HARRY'), ('CHRISTMAS MOONSHINE'), ('CHRONICLE VARGAS'),
58-
('CINCINATTI WHISPERER'), ('CITIZEN SHREK'), ('CITRUS CHILL'), ('CITY CASPER'),
59-
('CLAMPETT COMFORTS'), ('CLEOPATRA DEVIL'), ('CLERKS ANGELS'), ('CLOCKWORK PARADISE'),
60-
('CLONES PINOCCHIO'), ('CLOSER BANG'), ('CLUE GRAIL'), ('CLUBS ARIEL'),
61-
('CLYDE THEORY'), ('COAST RAINBOW'), ('COCKTAIL CASUALTY'), ('COCO JACKET'),
62-
('COLLISION STRANGER'), ('COLOR PHILADELPHIA');
63-
6429
-- Insert a few test films for other letters to test edge cases
6530
INSERT INTO film (title) VALUES
6631
('DANCING FEVER'), ('EAGLE LOVERBOY'), ('FAMILY SWEET'), ('GASOLINE DUDE'),

examples/spring-boot-demo/requirements/agile/US-001-film-query.feature

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,6 @@ Feature: Query Films Starting with Letter A
3535
And the response should have HTTP 200 OK status
3636
And the response should include a message indicating no films found
3737

38-
Scenario Outline: Query films by different starting letters
39-
Given the film database contains movies with various titles
40-
When I request films that start with the letter "<letter>"
41-
Then I should receive a list of films with titles beginning with "<letter>"
42-
And all returned film titles should start with the letter "<letter>"
43-
44-
Examples:
45-
| letter | expected_count |
46-
| A | 46 |
47-
| B | 54 |
48-
| C | 58 |
49-
5038
Scenario: Invalid query parameter handling
5139
Given the film query service is running
5240
When I make a GET request to "/api/v1/films" with an invalid filter parameter

0 commit comments

Comments
 (0)