1+ package pl .mperor .lab .java .design .pattern .behavioral .template .method ;
2+
3+ import org .junit .jupiter .api .Assertions ;
4+ import org .junit .jupiter .api .Test ;
5+ import pl .mperor .lab .common .TestUtils ;
6+
7+ public class BackupProcessTemplateTest {
8+
9+ @ Test
10+ public void shouldAllowToExecuteBackupProcessForDifferentDataSources () {
11+ var out = TestUtils .setTempSystemOut ();
12+ new DatabaseBackup ().execute ();
13+ Assertions .assertLinesMatch ("""
14+ ===== Database Backup =====
15+ 🗄️ Checking database connection...
16+ 💾 Dumping database to SQL file...
17+ ✅ Checking database dump integrity...
18+ 🧹 Deleting old backup files...
19+ """ .lines (), out .lines ().stream ());
20+
21+ out = TestUtils .setTempSystemOut ();
22+ new LocalFileBackup ().execute ();
23+ Assertions .assertLinesMatch ("""
24+ ===== File Backup =====
25+ 🔍 Checking disk space for backup...
26+ 📂 Copying files to backup directory...
27+ 🔢 Comparing checksums of original and copied files...
28+ 🧹 Deleting old backup files...
29+ """ .lines (), out .lines ().stream ());
30+
31+ TestUtils .resetSystemOut ();
32+ }
33+ }
0 commit comments