Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VOUCHERIFY_HOST=https://api.voucherify.io
VOUCHERIFY_HOST=https://eu1.api.voucherify.io ;keep in mind that cluster needs to be defined in provided url
X_APP_ID=
X_APP_TOKEN=
X_MANAGEMENT_ID=
X_MANAGEMENT_TOKEN=
X_MANAGEMENT_TOKEN=
24 changes: 10 additions & 14 deletions src/test/java/io/voucherify/ManagementTest.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
package io.voucherify;

import io.voucherify.data.VoucherifyStore;
import io.voucherify.helpers.JsonHelper;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import io.voucherify.data.VoucherifyStore;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.Order;

import io.voucherify.client.ApiClient;
import io.voucherify.client.api.ManagementApi;
import io.voucherify.client.model.*;
import io.voucherify.client.model.ManagementProjectsCustomEventSchemasCreateResponseBody.ObjectEnum;
import io.voucherify.client.model.ManagementProjectsMetadataSchemaDefinition.TypeEnum;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.io.InputStream;
import java.util.Properties;
import java.io.FileInputStream;
import java.io.IOException;

@org.junit.jupiter.api.Order(14)
Expand All @@ -32,7 +28,7 @@ public class ManagementTest {
public static ManagementApi managementApi = null;
public static String projectId = null;
public static String clusterId = null;
private static Properties properties = new Properties();
private static final Properties properties = new Properties();
private static InputStream input = null;

@BeforeAll
Expand All @@ -41,7 +37,7 @@ public static void beforeAll() {
// Load properties from .env file if it exists
try {
String dir = System.getProperty("user.dir");
input = new FileInputStream(dir + "/.env");
input = Files.newInputStream(Paths.get(dir + "/.env"));
properties.load(input);
} catch (IOException ex) {
System.out.println("[INFO] No .env file found, using environment variables");
Expand All @@ -61,7 +57,7 @@ public static void beforeAll() {

// Get VOUCHERIFY_HOST from environment variables or .env file
String voucherifyHost = System.getenv("VOUCHERIFY_HOST");
if ((voucherifyHost == null || voucherifyHost.isEmpty()) && properties != null) {
if (voucherifyHost == null || voucherifyHost.isEmpty()) {
voucherifyHost = properties.getProperty("VOUCHERIFY_HOST");
}

Expand All @@ -74,7 +70,7 @@ public static void beforeAll() {
}

// Default to 'eu1' if clusterId couldn't be determined or is too short
if (clusterId == null || clusterId.length() > 4) {
if (clusterId == null || clusterId.equals("API") || clusterId.length() > 4) {
clusterId = "eu1";
}

Expand Down