Skip to content

Package: TestSetLocator

TestSetLocator

nameinstructionbranchcomplexitylinemethod
allTestSets()
M: 9 C: 26
74%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 2 C: 7
78%
M: 0 C: 1
100%
getMusicTestSetsPath()
M: 6 C: 14
70%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 3
75%
M: 0 C: 1
100%
static {...}
M: 0 C: 14
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * blueMarine II: Semantic Media Centre
5: * http://tidalwave.it/projects/bluemarine2
6: *
7: * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/bluemarine2-src
23: * git clone https://github.com/tidalwave-it/bluemarine2-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.bluemarine2.commons.test;
28:
29: import javax.annotation.Nonnegative;
30: import javax.annotation.Nonnull;
31: import java.util.ArrayList;
32: import java.util.Collection;
33: import java.util.Collections;
34: import java.util.List;
35: import java.nio.file.Files;
36: import java.nio.file.Path;
37: import java.nio.file.Paths;
38: import lombok.NoArgsConstructor;
39: import lombok.extern.slf4j.Slf4j;
40: import static lombok.AccessLevel.PRIVATE;
41:
42: /***********************************************************************************************************************
43: *
44: * @author Fabrizio Giudici
45: *
46: **********************************************************************************************************************/
47: @NoArgsConstructor(access = PRIVATE) @Slf4j
48: public final class TestSetLocator
49: {
50: private static final String PROPERTY_TESTSET = "testSet";
51:
52: private static final String PROPERTY_SKIP_LONG_TESTS = "it.tidalwave-ci.skipLongTests";
53:
54: public static final Path PATH_TEST_RESULTS = Paths.get("target/test-results");
55:
56: public static final Path PATH_EXPECTED_TEST_RESULTS = Paths.get("target/test-classes/expected-results");
57:
58: public static final String PROPERTY_MUSIC_TEST_SETS_PATH = "blueMarine2.musicTestSets.path";
59:
60: /*******************************************************************************************************************
61: *
62: * TEST SETS:
63: *
64: * iTunes-fg-20160504-2
65: * ====================
66: *
67: * 52 records imported from CD by iTunes. 3 without CDDB - purportedly, so we can test that case.
68: *
69: * Spurious records "Callas - La Divina 2" (urn:bluemarine:record:d-B67tYwHDFv7ibEEJd8nsqMKIE=) and
70: * "La Divina 2" (urn:bluemarine:record:1YnSzOtRCbFKmcAnNRKLtDXCE8w=), regarding track #1.
71: *
72: *
73: * iTunes-fg-20161210-1
74: * ====================
75: *
76: * 228 records imported from CD by iTunes. 4 without CDDB - this will be fixed in future.
77: * Same spurious records as above.
78: *
79: *
80: * iTunes-aac-fg-20170131-1
81: * ========================
82: *
83: * 18 records from the iTunes Market, converted to MP3. They have embedded cover art.
84: *
85: *
86: * amazon-autorip-fg-20170131-1
87: * ============================
88: *
89: * 14 records from Amazon Autorip.
90: *
91: ******************************************************************************************************************/
92: @Nonnull
93: public static Collection<String> allTestSets()
94: {
95: final String testSet = System.getProperty(PROPERTY_TESTSET);
96:
97:• if (testSet != null)
98: {
99: return Collections.singletonList(testSet);
100: }
101:
102: final List<String> result = new ArrayList<>(List.of(
103: "iTunes-fg-20160504-2"));
104: final List<String> longTestSets = List.of(
105: "iTunes-fg-20161210-1",
106: "amazon-autorip-fg-20170131-1",
107: "iTunes-aac-fg-20170131-1");
108:
109:• if (Boolean.getBoolean(PROPERTY_SKIP_LONG_TESTS))
110: {
111: log.warn("{} set to true, skipping testsets: {}", PROPERTY_SKIP_LONG_TESTS, longTestSets);
112: }
113: else
114: {
115: result.addAll(longTestSets);
116: }
117:
118: return Collections.unmodifiableCollection(result);
119: }
120:
121: /*******************************************************************************************************************
122: *
123: ******************************************************************************************************************/
124: @Nonnegative
125: public static Path getMusicTestSetsPath()
126: {
127: final Path musicTestSets = Paths.get(System.getProperty(PROPERTY_MUSIC_TEST_SETS_PATH, "/doesNotExist"));
128:
129:• if (!Files.exists(musicTestSets))
130: {
131: throw new RuntimeException("Cannot run tests: set 'blueMarine2.musicTestSets.path' to the folder "
132: + "containing test sets (current value: " + musicTestSets + ")");
133: }
134:
135: return musicTestSets;
136: }
137: }