-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGitHubMapperTest.java
More file actions
62 lines (51 loc) · 2.27 KB
/
GitHubMapperTest.java
File metadata and controls
62 lines (51 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package net.lecigne.deezerdatasync.adapters.out.github;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import java.util.List;
import java.util.stream.Stream;
import net.lecigne.deezerdatasync.domain.common.DeezerData;
import net.lecigne.deezerdatasync.domain.playlist.Playlist;
import net.lecigne.deezerdatasync.domain.playlist.Playlist.PlaylistBuilder;
import net.lecigne.deezerdatasync.domain.playlist.PlaylistId;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
@DisplayName("The GitHub mapper")
class GitHubMapperTest {
@Test
void should_map_deezer_data_to_github_backup() {
// Given
DeezerData deezerData = GitHubFixtures.data();
GitHubBackup expectedBackup = GitHubFixtures.backup();
// When
GitHubBackup actualBackup = new GitHubMapper().mapDataToBackup(deezerData);
// Then
assertThat(actualBackup).usingRecursiveComparison().isEqualTo(expectedBackup);
}
@ParameterizedTest
@MethodSource("testData")
void should_create_clean_playlist_filenames(Playlist playlist, String path) {
// Given
var data = DeezerData.builder()
.albums(List.of())
.playlistInfos(List.of())
.playlists(List.of(playlist)).build();
// When
GitHubBackup actualBackup = new GitHubMapper().mapDataToBackup(data);
// Then
GitHubFile playlistFile = actualBackup.getGitHubFiles().get(3);
assertThat(playlistFile.getPath()).isEqualTo(path);
}
public static Stream<Arguments> testData() {
PlaylistBuilder<?, ?> p = Playlist.builder().playlistId(PlaylistId.of(42));
return Stream.of(
arguments(p.title("Hip-Hop").build(), "playlists/42_hip_hop.json"),
arguments(p.title("Funk and Soul").build(), "playlists/42_funk_and_soul.json"),
arguments(p.title("Funk & Soul").build(), "playlists/42_funk_soul.json"),
arguments(p.title("Downtempo / Nu Jazz").build(), "playlists/42_downtempo_nu_jazz.json"),
arguments(p.title("Drone Zone [Study / Relax / Meditate]").build(), "playlists/42_drone_zone_study_relax_meditate.json")
);
}
}