Import Test Data
Now that we have the restaurant creation functionality in place, we need to populate our application with test data for development and testing purposes.
Setting Up Test Resources
First, we need to create a directory to store our test images and populate it with sample restaurant photos.
Create a new directory at src/test/resources/testdata and add the following image files:
golden-dragon.pngla-petit-maison.pngraj-pavilion.pngsushi-master.pngrustic-olive.pngel-toro.pnggreek-house.pngseoul-kitchen.pngthai-orchid.pngburger-joint.png
Creating the Test Class
Let's create a test class that will help us load sample restaurant data into our application.
Create a new class at com.devtiro.restaurant.manual.RestaurantDataLoaderTest:
@SpringBootTest
@Tag("manual")
public class RestaurantDataLoaderTest {
@Autowired
private RestaurantService restaurantService;
@Autowired
private PhotoService photoService;
@Autowired
private ResourceLoader resourceLoader;
@Test
@Rollback(false) // Allow changes to persist
public void createSampleRestaurants() throws Exception {
// Test implementation provided in reference materials
}
}Summary
- Created test resources directory for sample restaurant images
- Implemented
RestaurantDataLoaderTestto populate test data