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

use variable in pipeline

Former-commit-id: 03665705
parent a18b599e
No related branches found
No related tags found
1 merge request!42Fixed the query service tests
...@@ -126,7 +126,7 @@ test-backend-table: ...@@ -126,7 +126,7 @@ test-backend-table:
stage: test-backend stage: test-backend
script: script:
- "./fda-table-service/rest-service/src/test/resources/integration-test.before" - "./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" - "./fda-table-service/rest-service/src/test/resources/integration-test.after"
- cat ./fda-table-service/report/target/site/jacoco-aggregate/index.html - cat ./fda-table-service/report/target/site/jacoco-aggregate/index.html
needs: needs:
......
...@@ -8,14 +8,18 @@ import org.springframework.context.annotation.Configuration; ...@@ -8,14 +8,18 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.DefaultUriTemplateHandler; import org.springframework.web.util.DefaultUriTemplateHandler;
import javax.validation.constraints.NotNull;
@Configuration @Configuration
public class ZenodoConfig { public class ZenodoConfig {
@Getter @Getter
@NotNull
@Value("${zenodo.endpoint}") @Value("${zenodo.endpoint}")
private String zenodoEndpoint; private String zenodoEndpoint;
@Getter @Getter
@NotNull
@Value("${zenodo.api_key}") @Value("${zenodo.api_key}")
private String zenodoApiKey; private String zenodoApiKey;
......
...@@ -34,9 +34,7 @@ public class ZenodoGateway { ...@@ -34,9 +34,7 @@ public class ZenodoGateway {
if (response.getBody() == null) { if (response.getBody() == null) {
throw new ZenodoApiException("Endpoint returned null body"); throw new ZenodoApiException("Endpoint returned null body");
} }
if (response.getBody().length == 0) {
throw new ZenodoApiException("Endpoint returned empty body");
}
return Arrays.asList(response.getBody()); 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 ...@@ -17,5 +17,4 @@ spring.jpa.show-sql=false
fda.mapping.path: /tmp fda.mapping.path: /tmp
fda.table.path: /tmp fda.table.path: /tmp
zenodo.api_key: df1eea59-7244-4930-9ee2-a48ed7dad615
zenodo.endpoint: https://sandbox.zenodo.org/ 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