Skip to content
Snippets Groups Projects
Unverified Commit 03665705 authored by Martin Weise's avatar Martin Weise
Browse files

use variable in pipeline

parent 4c0da8ac
Branches
Tags
3 merge requests!81New stable release,!43Merge dev to master,!27Draft: Resolve "Zenodo Sandbox integration for PID (e.g. DOI)"
......@@ -126,7 +126,7 @@ test-backend-table:
stage: test-backend
script:
- "./fda-table-service/rest-service/src/test/resources/integration-test.before"
- "mvn -f fda-table-service/pom.xml clean test verify"
- "mvn -f fda-table-service/pom.xml -DZENODO_API_KEY=${ZENODO_API_KEY} clean test verify"
- "./fda-table-service/rest-service/src/test/resources/integration-test.after"
- cat ./fda-table-service/report/target/site/jacoco-aggregate/index.html
needs:
......
......@@ -8,14 +8,18 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.DefaultUriTemplateHandler;
import javax.validation.constraints.NotNull;
@Configuration
public class ZenodoConfig {
@Getter
@NotNull
@Value("${zenodo.endpoint}")
private String zenodoEndpoint;
@Getter
@NotNull
@Value("${zenodo.api_key}")
private String zenodoApiKey;
......
......@@ -34,9 +34,7 @@ public class ZenodoGateway {
if (response.getBody() == null) {
throw new ZenodoApiException("Endpoint returned null body");
}
if (response.getBody().length == 0) {
throw new ZenodoApiException("Endpoint returned empty body");
}
return Arrays.asList(response.getBody());
}
}
package at.tuwien.gateway;
import at.tuwien.api.zenodo.deposit.DepositDto;
import at.tuwien.config.ReadyConfig;
import at.tuwien.exception.ZenodoApiException;
import at.tuwien.exception.ZenodoAuthenticationException;
import com.rabbitmq.client.Channel;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.client.RestTemplate;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
@SpringBootTest
@ExtendWith(SpringExtension.class)
public class ZenodoIntegrationTest extends BaseUnitTest {
@MockBean
private Channel channel;
@MockBean
private ReadyConfig readyConfig;
@Autowired
private ZenodoGateway zenodoGateway;
@Autowired
private RestTemplate zenodoTemplate;
@Test
public void listDeposit_succeeds() throws ZenodoApiException, ZenodoAuthenticationException {
/* test */
final List<DepositDto> response = zenodoGateway.listDeposits();
assertEquals(1, response.size());
assertEquals(DEPOSIT_1_ID, response.get(0).getId());
}
}
\ No newline at end of file
......@@ -17,5 +17,4 @@ spring.jpa.show-sql=false
fda.mapping.path: /tmp
fda.table.path: /tmp
zenodo.api_key: df1eea59-7244-4930-9ee2-a48ed7dad615
zenodo.endpoint: https://sandbox.zenodo.org/
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment