Skip to content

Commit 93228ee

Browse files
Add unit tests for SdkResourceLoader
1 parent 38b07db commit 93228ee

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package eu.europa.ted.eforms.sdk.resource;
2+
3+
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
5+
import java.io.IOException;
6+
import java.io.InputStream;
7+
import java.nio.file.Path;
8+
9+
import org.junit.jupiter.api.BeforeAll;
10+
import org.junit.jupiter.api.Test;
11+
12+
import eu.europa.ted.MavenTestSetup;
13+
import eu.europa.ted.eforms.sdk.SdkConstants;
14+
15+
public class SdkResourceLoaderTest extends MavenTestSetup {
16+
private static final Path SDK_ROOT_DIR = Path.of("target/eforms-sdk");
17+
18+
@BeforeAll
19+
static void downloadSdk() throws IOException {
20+
SdkDownloader.downloadSdk("1.1", SDK_ROOT_DIR);
21+
}
22+
23+
@Test
24+
void testGetResourceAsPath() {
25+
Path path = SdkResourceLoader.getResourceAsPath("1.1.3",
26+
SdkConstants.SdkResource.FIELDS_JSON, SDK_ROOT_DIR);
27+
28+
assertTrue(path.endsWith("fields/fields.json"));
29+
}
30+
31+
@Test
32+
void testGetResourceAsStream() throws IOException {
33+
InputStream is = SdkResourceLoader.getResourceAsStream("1.1.3",
34+
SdkConstants.SdkResource.FIELDS, "fields.json", SDK_ROOT_DIR);
35+
36+
assertTrue(is.read() >= 0);
37+
is.close();
38+
}
39+
}

0 commit comments

Comments
 (0)