Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ea 4015 move it #282

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions set-integration-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
<artifactId>set-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>eu.europeana.set</groupId>
<artifactId>set-client</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package eu.europeana.set.client.integration.web;
package eu.europeana.api.set.integration.client;

import eu.europeana.set.client.connection.BaseApiConnection;
import eu.europeana.set.definitions.model.vocabulary.WebUserSetFields;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

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

@Disabled("needs configuration file")
public class BaseAPIConnectionTest {
private static final String SERVICE_URI = "testUri";
private static final String API_KEY_1 = "api_key";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package eu.europeana.set.client.integration.web;
package eu.europeana.api.set.integration.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

import eu.europeana.api.set.integration.IntegrationTestSetup;
import eu.europeana.api.set.integration.config.SetIntegrationConfiguration;
import eu.europeana.set.client.config.ClientConfiguration;
import eu.europeana.set.client.exception.SetApiClientException;
import org.apache.hc.core5.http.HttpStatus;
Expand All @@ -15,7 +18,7 @@
import eu.europeana.set.definitions.model.UserSet;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class BaseWebUserSetProtocol {
public class BaseWebUserSetProtocol extends IntegrationTestSetup {

protected Logger log = LogManager.getLogger(getClass());

Expand All @@ -29,7 +32,21 @@ public class BaseWebUserSetProtocol {

@BeforeEach
public void initObjects() throws SetApiClientException {
apiClient = new UserSetApiClient(new ClientConfiguration());
apiClient = new UserSetApiClient( new ClientConfiguration(loadProperties()));
}

/**
* Create properties for set api localhost and regilar user token
* @return
*/
private Properties loadProperties() {
Properties properties = new Properties();
properties.put(ClientConfiguration.PROP_SET_SERVICE_URI, "localhost:8080/set");
properties.put(ClientConfiguration.PROP_SET_API_KEY, "test");
properties.put(ClientConfiguration.PROP_OAUTH_SERVICE_URI, SetIntegrationConfiguration.getInstance().getOauthServiceUri());
properties.put(ClientConfiguration.PROP_OAUTH_REQUEST_PARAMS, SetIntegrationConfiguration.getInstance().getOauthRequestParamsRegular());

return properties;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
package eu.europeana.set.client.integration.web;
package eu.europeana.api.set.integration.client;

import eu.europeana.set.client.config.ClientConfiguration;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.util.Properties;

import static org.junit.jupiter.api.Assertions.assertTrue;

@Disabled("needs configuration file")
public class ClientConfigurationTest {

@Test
public void clientConfiguration_loadProperties() {
ClientConfiguration configuration = new ClientConfiguration();
ClientConfiguration configuration = new ClientConfiguration(loadProperties());
assertTrue(StringUtils.isNotEmpty(configuration.getOauthRequestParams()));
assertTrue(StringUtils.isNotEmpty(configuration.getServiceUri()));
assertTrue(StringUtils.isNotEmpty(configuration.getOauthServiceUri()));
}

private Properties loadProperties() {
Properties properties = new Properties();
properties.put(ClientConfiguration.PROP_SET_SERVICE_URI, "service-ur-test");
properties.put(ClientConfiguration.PROP_SET_API_KEY, "test");
properties.put(ClientConfiguration.PROP_OAUTH_SERVICE_URI, "outh-test");
properties.put(ClientConfiguration.PROP_OAUTH_REQUEST_PARAMS, "params-test");

return properties;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.europeana.set.client.integration.web;
package eu.europeana.api.set.integration.client;

import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
Expand All @@ -14,7 +14,6 @@
*
* @author GrafR
*/
@Disabled
public class WebUserSetProtocolExceptionsTest extends BaseWebUserSetProtocol {

public String CORRUPTED_JSON =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package eu.europeana.set.client.integration.web;
package eu.europeana.api.set.integration.client;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import org.apache.hc.core5.http.HttpStatus;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import eu.europeana.set.client.exception.SetApiClientException;
Expand All @@ -14,12 +15,11 @@
* This is an integration test, and it is ignored for unit testing
* @author GrafR
*/
@Disabled
public class WebUserSetProtocolTest extends BaseWebUserSetProtocol {

@Test
public void createUserSet() throws SetApiClientException, IOException {
String setId = createTestUserSet(USER_SET_CONTENT, null);
String setId = createTestUserSetForClient(BaseWebUserSetProtocol.USER_SET_CONTENT, null);
assertNotNull(setId);
apiClient.getWebUserSetApi().deleteUserSet(setId);
}
Expand All @@ -31,7 +31,7 @@ public void createUserSet() throws SetApiClientException, IOException {
*/
@Test
public void retrieveUserSet() throws IllegalArgumentException, IOException, SetApiClientException {
String testSetId = createTestUserSet(USER_SET_CONTENT, null);
String testSetId = createTestUserSetForClient(BaseWebUserSetProtocol.USER_SET_CONTENT, null);
assertNotNull(testSetId);
// get user set by ID and user identifier
UserSet userSet = apiClient.getWebUserSetApi().getUserSet(testSetId, null);
Expand All @@ -41,10 +41,10 @@ public void retrieveUserSet() throws IllegalArgumentException, IOException, SetA

@Test
public void updateUserSet() throws IOException, SetApiClientException {
String testSetId = createTestUserSet(USER_SET_CONTENT, null);
String testSetId = createTestUserSetForClient(BaseWebUserSetProtocol.USER_SET_CONTENT, null);
assertNotNull(testSetId);
// updated user set value
String requestBody = getJsonStringInput(USER_SET_UPDATE_CONTENT);
String requestBody = getJsonStringInput(BaseWebUserSetProtocol.USER_SET_UPDATE_CONTENT);
assertNotNull(requestBody);
// update user set by identifier URL
UserSet updateResponse = apiClient.getWebUserSetApi().updateUserSet(
Expand All @@ -55,7 +55,7 @@ public void updateUserSet() throws IOException, SetApiClientException {

@Test
public void deleteUserSet() throws IOException, SetApiClientException {
String testSetId = createTestUserSet(USER_SET_CONTENT,null);
String testSetId = createTestUserSetForClient(BaseWebUserSetProtocol.USER_SET_CONTENT,null);
assertNotNull(testSetId);
// delete user set by identifier URL
String deleteResponse = apiClient.getWebUserSetApi().deleteUserSet(testSetId);
Expand All @@ -69,7 +69,7 @@ public void deleteUserSet() throws IOException, SetApiClientException {
* @return id of created user set
* @throws IOException
*/
private String createTestUserSet(String content, String profile) throws SetApiClientException, IOException {
private String createTestUserSetForClient(String content, String profile) throws SetApiClientException, IOException {
UserSet response = storeTestUserSet(content, profile);
return response.getIdentifier();
}
Expand Down
Loading