From 951720718fe2184c930d625504a742ebd8850da8 Mon Sep 17 00:00:00 2001 From: Martin Weise <martin.weise@tuwien.ac.at> Date: Thu, 12 Dec 2024 20:50:30 +0100 Subject: [PATCH] WIP --- dbrepo-data-service/pom.xml | 10 +- .../src/main/resources/application.yml | 23 +- .../java/at/tuwien/annotations/MockAmqp.java | 17 -- .../endpoint/SubsetEndpointUnitTest.java | 137 +++++----- .../endpoint/TableEndpointUnitTest.java | 257 +++++++++--------- .../MetadataServiceGatewayUnitTest.java | 83 +----- .../tuwien/mvc/ActuatorEndpointMvcTest.java | 2 - .../at/tuwien/mvc/OpenApiEndpointMvcTest.java | 1 - .../at/tuwien/mvc/SubsetEndpointMvcTest.java | 2 - .../service/SchemaServiceIntegrationTest.java | 8 +- .../service/TableServiceIntegrationTest.java | 4 +- .../validation/EndpointValidatorUnitTest.java | 6 - .../gateway/MetadataServiceGateway.java | 25 -- .../impl/MetadataServiceGatewayImpl.java | 66 +---- .../java/at/tuwien/mapper/DataMapper.java | 162 ----------- dbrepo-metadata-service/pom.xml | 7 +- .../src/main/resources/application.yml | 30 +- .../tuwien/mapper/MetadataMapperUnitTest.java | 2 +- ...nticationPrivilegedIntegrationMvcTest.java | 4 +- .../tuwien/service/TableServiceUnitTest.java | 2 +- .../main/java/at/tuwien/test/BaseTest.java | 12 +- 21 files changed, 258 insertions(+), 602 deletions(-) delete mode 100644 dbrepo-data-service/rest-service/src/test/java/at/tuwien/annotations/MockAmqp.java diff --git a/dbrepo-data-service/pom.xml b/dbrepo-data-service/pom.xml index 5f813b94c7..ee9a683dfb 100644 --- a/dbrepo-data-service/pom.xml +++ b/dbrepo-data-service/pom.xml @@ -44,7 +44,6 @@ <jwt.version>4.3.0</jwt.version> <opencsv.version>5.7.1</opencsv.version> <super-csv.version>2.4.0</super-csv.version> - <jsql.version>4.6</jsql.version> <springdoc-openapi.version>2.3.0</springdoc-openapi.version> <hsqldb.version>2.7.2</hsqldb.version> <testcontainers.version>1.19.1</testcontainers.version> @@ -64,6 +63,10 @@ </properties> <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-validation</artifactId> + </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> @@ -208,11 +211,6 @@ <artifactId>jackson-datatype-hibernate6</artifactId> <version>${jackson-datatype.version}</version> </dependency> - <dependency> - <groupId>com.github.jsqlparser</groupId> - <artifactId>jsqlparser</artifactId> - <version>${jsql.version}</version> - </dependency> <!-- Authentication --> <dependency> <groupId>com.auth0</groupId> diff --git a/dbrepo-data-service/rest-service/src/main/resources/application.yml b/dbrepo-data-service/rest-service/src/main/resources/application.yml index 9bd16e6089..c23c50bad6 100644 --- a/dbrepo-data-service/rest-service/src/main/resources/application.yml +++ b/dbrepo-data-service/rest-service/src/main/resources/application.yml @@ -3,27 +3,26 @@ application: version: '@project.version@' spring: datasource: - url: jdbc:h2:mem:fda;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS FDA;NON_KEYWORDS=value + url: "jdbc:h2:mem:dbrepo;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS dbrepo;NON_KEYWORDS=value" driver-class-name: org.h2.Driver username: sa password: password - rabbitmq: - host: "${BROKER_HOST:broker-service}" - virtual-host: "${BROKER_VIRTUALHOST:dbrepo}" - password: "${BROKER_PASSWORD:admin}" - username: "${BROKER_USERNAME:admin}" - port: ${BROKER_PORT:5672} jpa: show-sql: false - database-platform: org.hibernate.dialect.H2Dialect open-in-view: false properties: hibernate: - default_schema: fda + default_schema: "${METADATA_DB:dbrepo}" jdbc: time_zone: UTC application: name: data-service + rabbitmq: + host: "${BROKER_HOST:broker-service}" + virtual-host: "${BROKER_VIRTUALHOST:dbrepo}" + username: "${BROKER_USERNAME:admin}" + password: "${BROKER_PASSWORD:admin}" + port: ${BROKER_PORT:5672} main: banner-mode: off management: @@ -65,8 +64,8 @@ dbrepo: jwt: public_key: "${JWT_PUBKEY:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqqnHQ2BWWW9vDNLRCcxD++xZg/16oqMo/c1l+lcFEjjAIJjJp/HqrPYU/U9GvquGE6PbVFtTzW1KcKawOW+FJNOA3CGo8Q1TFEfz43B8rZpKsFbJKvQGVv1Z4HaKPvLUm7iMm8Hv91cLduuoWx6Q3DPe2vg13GKKEZe7UFghF+0T9u8EKzA/XqQ0OiICmsmYPbwvf9N3bCKsB/Y10EYmZRb8IhCoV9mmO5TxgWgiuNeCTtNCv2ePYqL/U0WvyGFW0reasIK8eg3KrAUj8DpyOgPOVBn3lBGf+3KFSYi+0bwZbJZWqbC/Xlk20Go1YfeJPRIt7ImxD27R/lNjgDO/MwIDAQAB}" keycloak: - username: "${AUTH_SERVICE_ADMIN:fda}" - password: "${AUTH_SERVICE_ADMIN_PASSWORD:fda}" + username: "${AUTH_SERVICE_ADMIN:admin}" + password: "${AUTH_SERVICE_ADMIN_PASSWORD:admin}" client: "${AUTH_SERVICE_CLIENT:dbrepo-client}" clientSecret: "${AUTH_SERVICE_CLIENT_SECRET:MUwRc7yfXSJwX8AdRMWaQC3Nep1VjwgG}" sql: @@ -81,4 +80,4 @@ dbrepo: queueName: "${BROKER_QUEUE_NAME:dbrepo}" exchangeName: "${BROKER_EXCHANGE_NAME:dbrepo}" routingKey: "${BROKER_ROUTING_KEY:#}" - connectionTimeout: ${CONNECTION_TIMEOUT:10000} + connectionTimeout: "${SPARQL_CONNECTION_TIMEOUT:10000}" diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/annotations/MockAmqp.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/annotations/MockAmqp.java deleted file mode 100644 index 0f3868c25e..0000000000 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/annotations/MockAmqp.java +++ /dev/null @@ -1,17 +0,0 @@ -package at.tuwien.annotations; - -import at.tuwien.listener.DefaultListener; -import com.rabbitmq.client.Channel; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.boot.test.mock.mockito.MockBeans; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -@MockBeans({@MockBean(Channel.class), @MockBean(DefaultListener.class)}) -public @interface MockAmqp { -} diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/SubsetEndpointUnitTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/SubsetEndpointUnitTest.java index c9e35bbabe..73a03a67f4 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/SubsetEndpointUnitTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/SubsetEndpointUnitTest.java @@ -394,28 +394,30 @@ public class SubsetEndpointUnitTest extends AbstractUnitTest { subsetEndpoint.create(DATABASE_3_ID, request, null, httpServletRequest, null, null, null); } -// @Test -// public void getData_succeeds() throws DatabaseNotFoundException, RemoteUnavailableException, UserNotFoundException, -// NotAllowedException, SQLException, QueryNotFoundException, TableMalformedException, QueryMalformedException, -// DatabaseUnavailableException, PaginationException, MetadataServiceException { -// -// /* mock */ -// when(metadataServiceGateway.getDatabaseById(DATABASE_3_ID)) -// .thenReturn(DATABASE_3_PRIVILEGED_DTO); -// when(subsetService.findById(DATABASE_3_PRIVILEGED_DTO, QUERY_5_ID)) -// .thenReturn(QUERY_5_DTO); -// when(subsetService.reExecuteCount(DATABASE_3_PRIVILEGED_DTO, QUERY_5_DTO)) -// .thenReturn(QUERY_5_RESULT_NUMBER); -// when(subsetService.reExecute(DATABASE_3_PRIVILEGED_DTO, QUERY_5_DTO, 0L, 10L, null, null)) -// .thenReturn(QUERY_5_RESULT_DTO); -// when(httpServletRequest.getMethod()) -// .thenReturn("GET"); -// -// /* test */ -// final ResponseEntity<List<Map<String, Object>>> response = subsetEndpoint.getData(DATABASE_3_ID, QUERY_5_ID, null, httpServletRequest, null, null); -// assertEquals(HttpStatus.OK, response.getStatusCode()); -// assertNotNull(response.getBody()); -// } + @Test + public void getData_succeeds() throws DatabaseNotFoundException, RemoteUnavailableException, UserNotFoundException, + NotAllowedException, SQLException, QueryNotFoundException, TableMalformedException, QueryMalformedException, + DatabaseUnavailableException, PaginationException, MetadataServiceException, TableNotFoundException, + ViewMalformedException, ViewNotFoundException { + final Dataset<Row> mock = sparkSession.emptyDataFrame(); + + /* mock */ + when(metadataServiceGateway.getDatabaseById(DATABASE_3_ID)) + .thenReturn(DATABASE_3_PRIVILEGED_DTO); + when(subsetService.findById(DATABASE_3_PRIVILEGED_DTO, QUERY_5_ID)) + .thenReturn(QUERY_5_DTO); + when(subsetService.reExecuteCount(DATABASE_3_PRIVILEGED_DTO, QUERY_5_DTO)) + .thenReturn(QUERY_5_RESULT_NUMBER); + when(subsetService.getData(DATABASE_3_PRIVILEGED_DTO, QUERY_5_DTO, 0L, 10L)) + .thenReturn(mock); + when(httpServletRequest.getMethod()) + .thenReturn("GET"); + + /* test */ + final ResponseEntity<List<Map<String, Object>>> response = subsetEndpoint.getData(DATABASE_3_ID, QUERY_5_ID, null, httpServletRequest, null, null); + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertNotNull(response.getBody()); + } @Test public void getData_head_succeeds() throws DatabaseNotFoundException, RemoteUnavailableException, @@ -441,29 +443,31 @@ public class SubsetEndpointUnitTest extends AbstractUnitTest { assertEquals(QUERY_5_RESULT_NUMBER, Long.parseLong(response.getHeaders().get("X-Count").get(0))); } -// @Test -// @WithMockUser(username = USER_1_USERNAME) -// public void getData_private_succeeds() throws DatabaseNotFoundException, RemoteUnavailableException, -// UserNotFoundException, DatabaseUnavailableException, NotAllowedException, TableMalformedException, -// QueryMalformedException, QueryNotFoundException, PaginationException, SQLException, MetadataServiceException { -// -// /* mock */ -// when(metadataServiceGateway.getDatabaseById(DATABASE_1_ID)) -// .thenReturn(DATABASE_1_PRIVILEGED_DTO); -// when(httpServletRequest.getMethod()) -// .thenReturn("GET"); -// when(subsetService.findById(DATABASE_1_PRIVILEGED_DTO, QUERY_1_ID)) -// .thenReturn(QUERY_1_DTO); -// when(subsetService.reExecuteCount(DATABASE_1_PRIVILEGED_DTO, QUERY_1_DTO)) -// .thenReturn(QUERY_1_RESULT_NUMBER); -// when(subsetService.reExecute(DATABASE_1_PRIVILEGED_DTO, QUERY_1_DTO, 0L, 10L, null, null)) -// .thenReturn(QUERY_1_RESULT_DTO); -// -// /* test */ -// final ResponseEntity<List<Map<String, Object>>> response = subsetEndpoint.getData(DATABASE_1_ID, QUERY_1_ID, USER_1_PRINCIPAL, httpServletRequest, null, null); -// assertEquals(HttpStatus.OK, response.getStatusCode()); -// assertNotNull(response.getBody()); -// } + @Test + @WithMockUser(username = USER_1_USERNAME) + public void getData_private_succeeds() throws DatabaseNotFoundException, RemoteUnavailableException, + UserNotFoundException, DatabaseUnavailableException, NotAllowedException, TableMalformedException, + QueryMalformedException, QueryNotFoundException, PaginationException, SQLException, + MetadataServiceException, TableNotFoundException, ViewMalformedException, ViewNotFoundException { + final Dataset<Row> mock = sparkSession.emptyDataFrame(); + + /* mock */ + when(metadataServiceGateway.getDatabaseById(DATABASE_1_ID)) + .thenReturn(DATABASE_1_PRIVILEGED_DTO); + when(httpServletRequest.getMethod()) + .thenReturn("GET"); + when(subsetService.findById(DATABASE_1_PRIVILEGED_DTO, QUERY_1_ID)) + .thenReturn(QUERY_1_DTO); + when(subsetService.reExecuteCount(DATABASE_1_PRIVILEGED_DTO, QUERY_1_DTO)) + .thenReturn(QUERY_1_RESULT_NUMBER); + when(subsetService.getData(DATABASE_1_PRIVILEGED_DTO, QUERY_1_DTO, 0L, 10L)) + .thenReturn(mock); + + /* test */ + final ResponseEntity<List<Map<String, Object>>> response = subsetEndpoint.getData(DATABASE_1_ID, QUERY_1_ID, USER_1_PRINCIPAL, httpServletRequest, null, null); + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertNotNull(response.getBody()); + } @Test @WithAnonymousUser @@ -523,27 +527,28 @@ public class SubsetEndpointUnitTest extends AbstractUnitTest { assertEquals(QUERY_1_RESULT_NUMBER, Long.parseLong(response.getHeaders().get("X-Count").get(0))); } -// @Test -// @WithMockUser(username = USER_1_USERNAME) -// public void getData_unavailable_fails() throws DatabaseNotFoundException, RemoteUnavailableException, SQLException, -// UserNotFoundException, QueryNotFoundException, MetadataServiceException, QueryMalformedException { -// -// /* mock */ -// when(metadataServiceGateway.getDatabaseById(DATABASE_1_ID)) -// .thenReturn(DATABASE_1_PRIVILEGED_DTO); -// when(subsetService.findById(DATABASE_1_PRIVILEGED_DTO, QUERY_1_ID)) -// .thenReturn(QUERY_1_DTO); -// when(httpServletRequest.getMethod()) -// .thenReturn("GET"); -// doThrow(SQLException.class) -// .when(subsetService) -// .reExecute(DATABASE_1_PRIVILEGED_DTO, QUERY_1_DTO, 0L, 10L, null, null); -// -// /* test */ -// assertThrows(DatabaseUnavailableException.class, () -> { -// subsetEndpoint.getData(DATABASE_1_ID, QUERY_1_ID, USER_1_PRINCIPAL, httpServletRequest, null, null); -// }); -// } + @Test + @WithMockUser(username = USER_1_USERNAME) + public void getData_unavailable_fails() throws DatabaseNotFoundException, RemoteUnavailableException, SQLException, + UserNotFoundException, QueryNotFoundException, MetadataServiceException, QueryMalformedException, + TableNotFoundException, ViewMalformedException { + + /* mock */ + when(metadataServiceGateway.getDatabaseById(DATABASE_1_ID)) + .thenReturn(DATABASE_1_PRIVILEGED_DTO); + when(subsetService.findById(DATABASE_1_PRIVILEGED_DTO, QUERY_1_ID)) + .thenReturn(QUERY_1_DTO); + when(httpServletRequest.getMethod()) + .thenReturn("GET"); + doThrow(SQLException.class) + .when(subsetService) + .getData(DATABASE_1_PRIVILEGED_DTO, QUERY_1_DTO, 0L, 10L); + + /* test */ + assertThrows(DatabaseUnavailableException.class, () -> { + subsetEndpoint.getData(DATABASE_1_ID, QUERY_1_ID, USER_1_PRINCIPAL, httpServletRequest, null, null); + }); + } @Test @WithMockUser(username = USER_3_USERNAME, authorities = {"persist-query"}) diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/TableEndpointUnitTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/TableEndpointUnitTest.java index 2bf1afb847..76bb8f82bb 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/TableEndpointUnitTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/endpoint/TableEndpointUnitTest.java @@ -1,5 +1,6 @@ package at.tuwien.endpoint; +import at.tuwien.api.database.DatabaseAccessDto; import at.tuwien.api.database.query.ImportDto; import at.tuwien.api.database.table.*; import at.tuwien.api.database.table.internal.PrivilegedTableDto; @@ -11,6 +12,9 @@ import at.tuwien.service.TableService; import at.tuwien.test.AbstractUnitTest; import jakarta.servlet.http.HttpServletRequest; import lombok.extern.log4j.Log4j2; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -20,6 +24,7 @@ import org.junit.jupiter.params.provider.MethodSource; 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.core.io.InputStreamResource; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.AccessDeniedException; @@ -28,12 +33,13 @@ import org.springframework.security.test.context.support.WithMockUser; import org.springframework.test.context.junit.jupiter.SpringExtension; import java.sql.SQLException; +import java.time.Instant; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Stream; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import static org.mockito.Mockito.*; @Log4j2 @@ -47,6 +53,9 @@ public class TableEndpointUnitTest extends AbstractUnitTest { @Autowired private HttpServletRequest httpServletRequest; + @Autowired + private SparkSession sparkSession; + @MockBean private TableService tableService; @@ -262,50 +271,52 @@ public class TableEndpointUnitTest extends AbstractUnitTest { }); } -// @Test -// @WithAnonymousUser -// public void getData_succeeds() throws DatabaseUnavailableException, TableNotFoundException, TableMalformedException, -// SQLException, QueryMalformedException, RemoteUnavailableException, PaginationException, MetadataServiceException, -// NotAllowedException { -// -// /* mock */ -// when(metadataServiceGateway.getTableById(DATABASE_3_ID, TABLE_8_ID)) -// .thenReturn(TABLE_8_PRIVILEGED_DTO); -// when(tableService.getPaginatedData(eq(TABLE_8_PRIVILEGED_DTO), any(Instant.class), eq(0L), eq(10L))) -// .thenReturn(TABLE_8_DATA_DTO); -// -// /* test */ -// final ResponseEntity<QueryResultDto> response = tableEndpoint.getData(DATABASE_3_ID, TABLE_8_ID, null, null, null, httpServletRequest, null); -// assertEquals(HttpStatus.OK, response.getStatusCode()); -// -// } -// -// @Test -// @WithAnonymousUser -// public void getData_head_succeeds() throws DatabaseUnavailableException, TableNotFoundException, TableMalformedException, -// SQLException, QueryMalformedException, RemoteUnavailableException, PaginationException, MetadataServiceException, -// NotAllowedException { -// final HttpServletRequest mock = mock(HttpServletRequest.class); -// -// /* mock */ -// when(metadataServiceGateway.getTableById(DATABASE_3_ID, TABLE_8_ID)) -// .thenReturn(TABLE_8_PRIVILEGED_DTO); -// when(mock.getMethod()) -// .thenReturn("HEAD"); -// when(tableService.getCount(eq(TABLE_8_PRIVILEGED_DTO), any(Instant.class))) -// .thenReturn(3L); -// when(tableService.getPaginatedData(eq(TABLE_8_PRIVILEGED_DTO), any(Instant.class), eq(0L), eq(10L))) -// .thenReturn(TABLE_8_DATA_DTO); -// -// /* test */ -// final ResponseEntity<QueryResultDto> response = tableEndpoint.getData(DATABASE_3_ID, TABLE_8_ID, null, null, null, mock, null); -// assertEquals(HttpStatus.OK, response.getStatusCode()); -// assertNotNull(response.getHeaders().get("Access-Control-Expose-Headers")); -// assertEquals("X-Count", response.getHeaders().get("Access-Control-Expose-Headers").get(0)); -// assertNotNull(response.getHeaders().get("X-Count")); -// assertEquals("3", response.getHeaders().get("X-Count").get(0)); -// -// } + @Test + @WithAnonymousUser + public void getData_succeeds() throws DatabaseUnavailableException, TableNotFoundException, QueryMalformedException, + RemoteUnavailableException, PaginationException, MetadataServiceException, NotAllowedException { + final Dataset<Row> mock = sparkSession.emptyDataFrame(); + + /* mock */ + when(metadataServiceGateway.getTableById(DATABASE_3_ID, TABLE_8_ID)) + .thenReturn(TABLE_8_PRIVILEGED_DTO); + when(tableService.getData(eq(DATABASE_3_PRIVILEGED_DTO), eq(TABLE_8_INTERNAL_NAME), any(Instant.class), eq(0L), eq(10L), eq(null), eq(null))) + .thenReturn(mock); + when(httpServletRequest.getMethod()) + .thenReturn("GET"); + + /* test */ + final ResponseEntity<List<Map<String, Object>>> response = tableEndpoint.getData(DATABASE_3_ID, TABLE_8_ID, null, null, null, httpServletRequest, null); + assertEquals(HttpStatus.OK, response.getStatusCode()); + + } + + @Test + @WithAnonymousUser + public void getData_head_succeeds() throws DatabaseUnavailableException, TableNotFoundException, + SQLException, QueryMalformedException, RemoteUnavailableException, PaginationException, + MetadataServiceException, NotAllowedException { + final Dataset<Row> mock = sparkSession.emptyDataFrame(); + + /* mock */ + when(metadataServiceGateway.getTableById(DATABASE_3_ID, TABLE_8_ID)) + .thenReturn(TABLE_8_PRIVILEGED_DTO); + when(tableService.getCount(eq(TABLE_8_PRIVILEGED_DTO), any(Instant.class))) + .thenReturn(3L); + when(tableService.getData(eq(DATABASE_3_PRIVILEGED_DTO), eq(TABLE_8_INTERNAL_NAME), any(Instant.class), eq(0L), eq(10L), eq(null), eq(null))) + .thenReturn(mock); + when(httpServletRequest.getMethod()) + .thenReturn("HEAD"); + + /* test */ + final ResponseEntity<List<Map<String, Object>>> response = tableEndpoint.getData(DATABASE_3_ID, TABLE_8_ID, null, null, null, httpServletRequest, null); + assertEquals(HttpStatus.OK, response.getStatusCode()); + assertNotNull(response.getHeaders().get("Access-Control-Expose-Headers")); + assertEquals("X-Count", response.getHeaders().get("Access-Control-Expose-Headers").get(0)); + assertNotNull(response.getHeaders().get("X-Count")); + assertEquals("3", response.getHeaders().get("X-Count").get(0)); + + } @Test @WithAnonymousUser @@ -340,23 +351,23 @@ public class TableEndpointUnitTest extends AbstractUnitTest { }); } -// @Test -// @WithAnonymousUser -// public void getData_unavailable_fails() throws TableNotFoundException, RemoteUnavailableException, -// MetadataServiceException, TableMalformedException, SQLException { -// -// /* mock */ -// when(metadataServiceGateway.getTableById(DATABASE_3_ID, TABLE_8_ID)) -// .thenReturn(TABLE_8_PRIVILEGED_DTO); -// doThrow(SQLException.class) -// .when(tableService) -// .getPaginatedData(eq(TABLE_8_PRIVILEGED_DTO), any(Instant.class), eq(0L), eq(10L)); -// -// /* test */ -// assertThrows(DatabaseUnavailableException.class, () -> { -// tableEndpoint.getData(DATABASE_3_ID, TABLE_8_ID, null, null, null, httpServletRequest, null); -// }); -// } + @Test + @WithAnonymousUser + public void getData_unavailable_fails() throws TableNotFoundException, RemoteUnavailableException, + MetadataServiceException, QueryMalformedException { + + /* mock */ + when(metadataServiceGateway.getTableById(DATABASE_3_ID, TABLE_8_ID)) + .thenReturn(TABLE_8_PRIVILEGED_DTO); + doThrow(SQLException.class) + .when(tableService) + .getData(eq(DATABASE_3_PRIVILEGED_DTO), eq(TABLE_8_INTERNAL_NAME), any(Instant.class), eq(0L), eq(10L), eq(null), eq(null)); + + /* test */ + assertThrows(DatabaseUnavailableException.class, () -> { + tableEndpoint.getData(DATABASE_3_ID, TABLE_8_ID, null, null, null, httpServletRequest, null); + }); + } @Test @WithMockUser(username = USER_2_USERNAME) @@ -376,25 +387,26 @@ public class TableEndpointUnitTest extends AbstractUnitTest { }); } -// @ParameterizedTest -// @WithMockUser(username = USER_2_USERNAME) -// @MethodSource("anyAccess_parameters") -// public void getData_private_succeeds(String name, DatabaseAccessDto access) throws DatabaseUnavailableException, -// TableNotFoundException, TableMalformedException, SQLException, QueryMalformedException, -// RemoteUnavailableException, PaginationException, MetadataServiceException, NotAllowedException { -// -// /* mock */ -// when(metadataServiceGateway.getTableById(DATABASE_1_ID, TABLE_1_ID)) -// .thenReturn(TABLE_1_PRIVILEGED_DTO); -// when(metadataServiceGateway.getAccess(DATABASE_1_ID, USER_2_ID)) -// .thenReturn(access); -// when(tableService.getPaginatedData(eq(TABLE_1_PRIVILEGED_DTO), any(Instant.class), eq(0L), eq(10L))) -// .thenReturn(TABLE_1_DATA_DTO); -// -// /* test */ -// final ResponseEntity<QueryResultDto> response = tableEndpoint.getData(DATABASE_1_ID, TABLE_1_ID, null, null, null, httpServletRequest, USER_2_PRINCIPAL); -// assertEquals(HttpStatus.OK, response.getStatusCode()); -// } + @ParameterizedTest + @WithMockUser(username = USER_2_USERNAME) + @MethodSource("anyAccess_parameters") + public void getData_private_succeeds(String name, DatabaseAccessDto access) throws DatabaseUnavailableException, + TableNotFoundException, QueryMalformedException, RemoteUnavailableException, PaginationException, + MetadataServiceException, NotAllowedException { + final Dataset<Row> mock = sparkSession.emptyDataFrame(); + + /* mock */ + when(metadataServiceGateway.getTableById(DATABASE_1_ID, TABLE_1_ID)) + .thenReturn(TABLE_1_PRIVILEGED_DTO); + when(metadataServiceGateway.getAccess(DATABASE_1_ID, USER_2_ID)) + .thenReturn(access); + when(tableService.getData(eq(DATABASE_1_PRIVILEGED_DTO), eq(TABLE_1_INTERNAL_NAME), any(Instant.class), eq(0L), eq(10L), eq(null), eq(null))) + .thenReturn(mock); + + /* test */ + final ResponseEntity<List<Map<String, Object>>> response = tableEndpoint.getData(DATABASE_1_ID, TABLE_1_ID, null, null, null, httpServletRequest, USER_2_PRINCIPAL); + assertEquals(HttpStatus.OK, response.getStatusCode()); + } @Test @WithAnonymousUser @@ -1118,50 +1130,43 @@ public class TableEndpointUnitTest extends AbstractUnitTest { }); } -// @Test -// @WithAnonymousUser -// public void exportData_succeeds() throws DatabaseUnavailableException, TableNotFoundException, NotAllowedException, -// StorageUnavailableException, QueryMalformedException, RemoteUnavailableException, StorageNotFoundException, -// SQLException, MetadataServiceException, MalformedException { -// final ExportResourceDto mock = ExportResourceDto.builder() -// .filename("deadbeef") -// .resource(new InputStreamResource(InputStream.nullInputStream())) -// .build(); -// -// /* mock */ -// when(metadataServiceGateway.getTableById(DATABASE_3_ID, TABLE_8_ID)) -// .thenReturn(TABLE_8_PRIVILEGED_DTO); -// when(tableService.exportDataset(eq(TABLE_8_PRIVILEGED_DTO), any(Instant.class))) -// .thenReturn(mock); -// -// /* test */ -// final ResponseEntity<InputStreamResource> response = tableEndpoint.exportDataset(DATABASE_3_ID, TABLE_8_ID, null, null); -// assertEquals(HttpStatus.OK, response.getStatusCode()); -// } -// -// @ParameterizedTest -// @WithMockUser(username = USER_2_USERNAME) -// @MethodSource("anyAccess_parameters") -// public void exportData_private_succeeds(String name, DatabaseAccessDto access) throws TableNotFoundException, -// NotAllowedException, StorageUnavailableException, QueryMalformedException, RemoteUnavailableException, -// MetadataServiceException, MalformedException { -// final ExportResourceDto mock = ExportResourceDto.builder() -// .filename("deadbeef") -// .resource(new InputStreamResource(InputStream.nullInputStream())) -// .build(); -// -// /* mock */ -// when(metadataServiceGateway.getTableById(DATABASE_1_ID, TABLE_1_ID)) -// .thenReturn(TABLE_1_PRIVILEGED_DTO); -// when(metadataServiceGateway.getAccess(DATABASE_1_ID, USER_2_ID)) -// .thenReturn(access); -// when(tableService.exportDataset(eq(TABLE_1_PRIVILEGED_DTO), any(Instant.class))) -// .thenReturn(mock); -// -// /* test */ -// final ResponseEntity<InputStreamResource> response = tableEndpoint.exportDataset(DATABASE_1_ID, TABLE_1_ID, null, USER_2_PRINCIPAL); -// assertEquals(HttpStatus.OK, response.getStatusCode()); -// } + @Test + @WithAnonymousUser + public void exportData_succeeds() throws TableNotFoundException, NotAllowedException, + StorageUnavailableException, QueryMalformedException, RemoteUnavailableException, MetadataServiceException { + final Dataset<Row> mock = sparkSession.emptyDataFrame(); + + /* mock */ + when(metadataServiceGateway.getTableById(DATABASE_3_ID, TABLE_8_ID)) + .thenReturn(TABLE_8_PRIVILEGED_DTO); + when(tableService.getData(eq(DATABASE_3_PRIVILEGED_DTO), eq(TABLE_8_INTERNAL_NAME), any(Instant.class), anyLong(), anyLong(), eq(null), eq(null))) + .thenReturn(mock); + + /* test */ + final ResponseEntity<InputStreamResource> response = tableEndpoint.exportDataset(DATABASE_3_ID, TABLE_8_ID, null, null); + assertEquals(HttpStatus.OK, response.getStatusCode()); + } + + @ParameterizedTest + @WithMockUser(username = USER_2_USERNAME) + @MethodSource("anyAccess_parameters") + public void exportData_private_succeeds(String name, DatabaseAccessDto access) throws TableNotFoundException, + NotAllowedException, StorageUnavailableException, QueryMalformedException, RemoteUnavailableException, + MetadataServiceException { + final Dataset<Row> mock = sparkSession.emptyDataFrame(); + + /* mock */ + when(metadataServiceGateway.getTableById(DATABASE_1_ID, TABLE_1_ID)) + .thenReturn(TABLE_1_PRIVILEGED_DTO); + when(metadataServiceGateway.getAccess(DATABASE_1_ID, USER_2_ID)) + .thenReturn(access); + when(tableService.getData(eq(DATABASE_1_PRIVILEGED_DTO), eq(TABLE_1_INTERNAL_NAME), any(Instant.class), anyLong(), anyLong(), eq(null), eq(null))) + .thenReturn(mock); + + /* test */ + final ResponseEntity<InputStreamResource> response = tableEndpoint.exportDataset(DATABASE_1_ID, TABLE_1_ID, null, USER_2_PRINCIPAL); + assertEquals(HttpStatus.OK, response.getStatusCode()); + } @Test @WithMockUser(username = USER_4_USERNAME) diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/gateway/MetadataServiceGatewayUnitTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/gateway/MetadataServiceGatewayUnitTest.java index 2730e94d9c..939d8b5eac 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/gateway/MetadataServiceGatewayUnitTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/gateway/MetadataServiceGatewayUnitTest.java @@ -31,7 +31,8 @@ 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.*; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; @@ -62,7 +63,7 @@ public class MetadataServiceGatewayUnitTest extends AbstractUnitTest { headers.set("X-Username", CONTAINER_1_PRIVILEGED_USERNAME); headers.set("X-Password", CONTAINER_1_PRIVILEGED_PASSWORD); headers.set("X-Database", DATABASE_1_INTERNALNAME); - headers.set("X-Table", TABLE_1_INTERNALNAME); + headers.set("X-Table", TABLE_1_INTERNAL_NAME); /* mock */ when(restTemplate.exchange(anyString(), eq(HttpMethod.GET), eq(HttpEntity.EMPTY), eq(TableDto.class))) @@ -78,7 +79,7 @@ public class MetadataServiceGatewayUnitTest extends AbstractUnitTest { assertEquals(CONTAINER_1_PRIVILEGED_USERNAME, response.getDatabase().getContainer().getUsername()); assertEquals(CONTAINER_1_PRIVILEGED_PASSWORD, response.getDatabase().getContainer().getPassword()); assertEquals(DATABASE_1_INTERNALNAME, response.getDatabase().getInternalName()); - assertEquals(TABLE_1_INTERNALNAME, response.getInternalName()); + assertEquals(TABLE_1_INTERNAL_NAME, response.getInternalName()); } @Test @@ -153,7 +154,7 @@ public class MetadataServiceGatewayUnitTest extends AbstractUnitTest { headers.set("X-Username", CONTAINER_1_PRIVILEGED_USERNAME); headers.set("X-Password", CONTAINER_1_PRIVILEGED_PASSWORD); headers.set("X-Database", DATABASE_1_INTERNALNAME); - headers.set("X-Table", TABLE_1_INTERNALNAME); + headers.set("X-Table", TABLE_1_INTERNAL_NAME); /* mock */ when(restTemplate.exchange(anyString(), eq(HttpMethod.GET), eq(HttpEntity.EMPTY), eq(TableDto.class))) @@ -167,80 +168,6 @@ public class MetadataServiceGatewayUnitTest extends AbstractUnitTest { }); } - @Test - public void getDatabaseByInternalName_succeeds() throws DatabaseNotFoundException, RemoteUnavailableException, - MetadataServiceException { - - /* mock */ - final HttpHeaders headers = new HttpHeaders(); - headers.set("X-Username", CONTAINER_1_PRIVILEGED_USERNAME); - headers.set("X-Password", CONTAINER_1_PRIVILEGED_PASSWORD); - when(restTemplate.exchange(anyString(), eq(HttpMethod.GET), eq(HttpEntity.EMPTY), eq(PrivilegedDatabaseDto[].class))) - .thenReturn(ResponseEntity.status(HttpStatus.OK) - .headers(headers) - .body(new PrivilegedDatabaseDto[]{DATABASE_1_PRIVILEGED_DTO})); - - /* test */ - final PrivilegedDatabaseDto response = metadataServiceGateway.getDatabaseByInternalName(DATABASE_1_INTERNALNAME); - assertEquals(response.getId(), response.getId()); - } - - @Test - public void getDatabaseByInternalName_unavailable_fails() { - - /* mock */ - doThrow(HttpServerErrorException.ServiceUnavailable.class) - .when(restTemplate) - .exchange(anyString(), eq(HttpMethod.GET), eq(HttpEntity.EMPTY), eq(PrivilegedDatabaseDto[].class)); - - /* test */ - assertThrows(RemoteUnavailableException.class, () -> { - metadataServiceGateway.getDatabaseByInternalName(DATABASE_1_INTERNALNAME); - }); - } - - @Test - public void getDatabaseByInternalName_statusCode_fails() { - - /* mock */ - when(restTemplate.exchange(anyString(), eq(HttpMethod.GET), eq(HttpEntity.EMPTY), eq(PrivilegedDatabaseDto[].class))) - .thenReturn(ResponseEntity.status(HttpStatus.NO_CONTENT) - .body(new PrivilegedDatabaseDto[]{DATABASE_1_PRIVILEGED_DTO})); - - /* test */ - assertThrows(MetadataServiceException.class, () -> { - metadataServiceGateway.getDatabaseByInternalName(DATABASE_1_INTERNALNAME); - }); - } - - @Test - public void getDatabaseByInternalName_emptyBody_fails() { - - /* mock */ - when(restTemplate.exchange(anyString(), eq(HttpMethod.GET), eq(HttpEntity.EMPTY), eq(PrivilegedDatabaseDto[].class))) - .thenReturn(ResponseEntity.ok() - .build()); - - /* test */ - assertThrows(DatabaseNotFoundException.class, () -> { - metadataServiceGateway.getDatabaseByInternalName(DATABASE_1_INTERNALNAME); - }); - } - - @Test - public void getDatabaseByInternalName_notFound_fails() { - - /* mock */ - when(restTemplate.exchange(anyString(), eq(HttpMethod.GET), eq(HttpEntity.EMPTY), eq(PrivilegedDatabaseDto[].class))) - .thenReturn(ResponseEntity.ok() - .body(new PrivilegedDatabaseDto[]{})); - - /* test */ - assertThrows(DatabaseNotFoundException.class, () -> { - metadataServiceGateway.getDatabaseByInternalName(DATABASE_1_INTERNALNAME); - }); - } - @Test public void getDatabaseById_succeeds() throws RemoteUnavailableException, MetadataServiceException, DatabaseNotFoundException { diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/ActuatorEndpointMvcTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/ActuatorEndpointMvcTest.java index f074abcc87..a7a83a6184 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/ActuatorEndpointMvcTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/ActuatorEndpointMvcTest.java @@ -1,6 +1,5 @@ package at.tuwien.mvc; -import at.tuwien.annotations.MockAmqp; import at.tuwien.test.AbstractUnitTest; import lombok.extern.log4j.Log4j2; import org.junit.jupiter.api.Test; @@ -21,7 +20,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @AutoConfigureMockMvc @SpringBootTest @AutoConfigureObservability -@MockAmqp public class ActuatorEndpointMvcTest extends AbstractUnitTest { @Autowired diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/OpenApiEndpointMvcTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/OpenApiEndpointMvcTest.java index d1426cdf69..b5ed475ea8 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/OpenApiEndpointMvcTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/OpenApiEndpointMvcTest.java @@ -12,7 +12,6 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.web.servlet.MockMvc; diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/SubsetEndpointMvcTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/SubsetEndpointMvcTest.java index 94341550a3..6a3851b445 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/SubsetEndpointMvcTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/mvc/SubsetEndpointMvcTest.java @@ -1,6 +1,5 @@ package at.tuwien.mvc; -import at.tuwien.annotations.MockAmqp; import at.tuwien.gateway.MetadataServiceGateway; import at.tuwien.service.SubsetService; import at.tuwien.test.AbstractUnitTest; @@ -26,7 +25,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @AutoConfigureMockMvc @SpringBootTest @AutoConfigureObservability -@MockAmqp public class SubsetEndpointMvcTest extends AbstractUnitTest { @MockBean diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/SchemaServiceIntegrationTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/SchemaServiceIntegrationTest.java index 23503384b6..96d78da001 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/SchemaServiceIntegrationTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/SchemaServiceIntegrationTest.java @@ -196,8 +196,8 @@ public class SchemaServiceIntegrationTest extends AbstractUnitTest { assertNotNull(unique0.getTable()); assertEquals("some_constraint", unique0.getName()); assertNull(unique0.getTable().getId()); - assertEquals(TABLE_1_INTERNALNAME, unique0.getTable().getName()); - assertEquals(TABLE_1_INTERNALNAME, unique0.getTable().getInternalName()); + assertEquals(TABLE_1_INTERNAL_NAME, unique0.getTable().getName()); + assertEquals(TABLE_1_INTERNAL_NAME, unique0.getTable().getInternalName()); assertEquals(TABLE_1_DESCRIPTION, unique0.getTable().getDescription()); assertTrue(unique0.getTable().getIsVersioned()); assertNotNull(unique0.getColumns()); @@ -235,8 +235,8 @@ public class SchemaServiceIntegrationTest extends AbstractUnitTest { final TableBriefDto fk0table = fk0.getTable(); assertNull(fk0table.getId()); assertEquals(DATABASE_1_ID, fk0table.getDatabaseId()); - assertEquals(TABLE_1_INTERNALNAME, fk0table.getName()); - assertEquals(TABLE_1_INTERNALNAME, fk0table.getInternalName()); + assertEquals(TABLE_1_INTERNAL_NAME, fk0table.getName()); + assertEquals(TABLE_1_INTERNAL_NAME, fk0table.getInternalName()); assertNotNull(fk0.getOnDelete()); assertNotNull(fk0.getOnUpdate()); assertNotNull(fk0.getReferencedTable()); diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/TableServiceIntegrationTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/TableServiceIntegrationTest.java index e2a48631d5..1236c549d7 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/TableServiceIntegrationTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/service/TableServiceIntegrationTest.java @@ -607,12 +607,12 @@ public class TableServiceIntegrationTest extends AbstractUnitTest { TableExistsException { /* mock */ - MariaDbConfig.dropTable(DATABASE_1_PRIVILEGED_DTO, TABLE_1_INTERNALNAME); + MariaDbConfig.dropTable(DATABASE_1_PRIVILEGED_DTO, TABLE_1_INTERNAL_NAME); /* test */ final TableDto response = tableService.createTable(DATABASE_1_PRIVILEGED_DTO, TABLE_1_CREATE_INTERNAL_DTO); assertEquals(TABLE_1_NAME, response.getName()); - assertEquals(TABLE_1_INTERNALNAME, response.getInternalName()); + assertEquals(TABLE_1_INTERNAL_NAME, response.getInternalName()); assertEquals(TABLE_1_COLUMNS.size(), response.getColumns().size()); } diff --git a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/validation/EndpointValidatorUnitTest.java b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/validation/EndpointValidatorUnitTest.java index b12313dfe9..e237c32d28 100644 --- a/dbrepo-data-service/rest-service/src/test/java/at/tuwien/validation/EndpointValidatorUnitTest.java +++ b/dbrepo-data-service/rest-service/src/test/java/at/tuwien/validation/EndpointValidatorUnitTest.java @@ -1,6 +1,5 @@ package at.tuwien.validation; -import at.tuwien.annotations.MockAmqp; import at.tuwien.exception.PaginationException; import at.tuwien.exception.QueryNotSupportedException; import at.tuwien.test.AbstractUnitTest; @@ -12,19 +11,14 @@ import org.springframework.boot.test.autoconfigure.actuate.observability.AutoCon import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.test.web.servlet.MockMvc; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @Log4j2 @ExtendWith(SpringExtension.class) @AutoConfigureMockMvc @SpringBootTest @AutoConfigureObservability -@MockAmqp public class EndpointValidatorUnitTest extends AbstractUnitTest { @Autowired diff --git a/dbrepo-data-service/services/src/main/java/at/tuwien/gateway/MetadataServiceGateway.java b/dbrepo-data-service/services/src/main/java/at/tuwien/gateway/MetadataServiceGateway.java index 282e7d593f..6575913040 100644 --- a/dbrepo-data-service/services/src/main/java/at/tuwien/gateway/MetadataServiceGateway.java +++ b/dbrepo-data-service/services/src/main/java/at/tuwien/gateway/MetadataServiceGateway.java @@ -4,11 +4,9 @@ import at.tuwien.api.container.internal.PrivilegedContainerDto; import at.tuwien.api.database.DatabaseAccessDto; import at.tuwien.api.database.internal.PrivilegedDatabaseDto; import at.tuwien.api.database.internal.PrivilegedViewDto; -import at.tuwien.api.database.table.TableStatisticDto; import at.tuwien.api.database.table.internal.PrivilegedTableDto; import at.tuwien.api.identifier.IdentifierDto; import at.tuwien.api.user.PrivilegedUserDto; -import at.tuwien.api.user.UserBriefDto; import at.tuwien.api.user.UserDto; import at.tuwien.exception.*; import jakarta.validation.constraints.NotNull; @@ -42,18 +40,6 @@ public interface MetadataServiceGateway { PrivilegedDatabaseDto getDatabaseById(Long id) throws DatabaseNotFoundException, RemoteUnavailableException, MetadataServiceException; - /** - * Get a database with given internal name from the metadata service. - * - * @param internalName The internal name. - * @return The database, if successful. - * @throws DatabaseNotFoundException The database was not found in the metadata service. - * @throws RemoteUnavailableException The remote service is not available. - * @throws MetadataServiceException The remote service returned invalid data. - */ - PrivilegedDatabaseDto getDatabaseByInternalName(String internalName) throws DatabaseNotFoundException, - RemoteUnavailableException, MetadataServiceException; - /** * Get a table with given database id and table id from the metadata service. * @@ -91,17 +77,6 @@ public interface MetadataServiceGateway { */ UserDto getUserById(UUID userId) throws RemoteUnavailableException, UserNotFoundException, MetadataServiceException; - /** - * Get a user with given username from the metadata service. - * - * @return The user, if successful. Otherwise empty list. - * @throws RemoteUnavailableException The remote service is not available and invalid data was returned. - * @throws UserNotFoundException The user was not found in the metadata service. - * @throws MetadataServiceException The remote service returned invalid data. - */ - UUID getSystemUserId() throws RemoteUnavailableException, UserNotFoundException, - MetadataServiceException; - /** * Get a user with given user id from the metadata service. * diff --git a/dbrepo-data-service/services/src/main/java/at/tuwien/gateway/impl/MetadataServiceGatewayImpl.java b/dbrepo-data-service/services/src/main/java/at/tuwien/gateway/impl/MetadataServiceGatewayImpl.java index 3c03f022b3..d83a06389d 100644 --- a/dbrepo-data-service/services/src/main/java/at/tuwien/gateway/impl/MetadataServiceGatewayImpl.java +++ b/dbrepo-data-service/services/src/main/java/at/tuwien/gateway/impl/MetadataServiceGatewayImpl.java @@ -10,9 +10,7 @@ import at.tuwien.api.database.table.TableDto; import at.tuwien.api.database.table.internal.PrivilegedTableDto; import at.tuwien.api.identifier.IdentifierDto; import at.tuwien.api.user.PrivilegedUserDto; -import at.tuwien.api.user.UserBriefDto; import at.tuwien.api.user.UserDto; -import at.tuwien.config.GatewayConfig; import at.tuwien.exception.*; import at.tuwien.gateway.MetadataServiceGateway; import at.tuwien.mapper.MetadataMapper; @@ -37,14 +35,11 @@ import java.util.UUID; public class MetadataServiceGatewayImpl implements MetadataServiceGateway { private final RestTemplate restTemplate; - private final GatewayConfig gatewayConfig; private final MetadataMapper metadataMapper; @Autowired - public MetadataServiceGatewayImpl(RestTemplate restTemplate, GatewayConfig gatewayConfig, - MetadataMapper metadataMapper) { + public MetadataServiceGatewayImpl(RestTemplate restTemplate, MetadataMapper metadataMapper) { this.restTemplate = restTemplate; - this.gatewayConfig = gatewayConfig; this.metadataMapper = metadataMapper; } @@ -121,37 +116,6 @@ public class MetadataServiceGatewayImpl implements MetadataServiceGateway { return database; } - @Override - public PrivilegedDatabaseDto getDatabaseByInternalName(String internalName) throws DatabaseNotFoundException, - RemoteUnavailableException, MetadataServiceException { - final ResponseEntity<PrivilegedDatabaseDto[]> response; - final String url = "/api/database/"; - log.debug("find privileged database from url: {}", url); - try { - response = restTemplate.exchange(url, HttpMethod.GET, HttpEntity.EMPTY, PrivilegedDatabaseDto[].class); - } catch (ResourceAccessException | HttpServerErrorException e) { - log.error("Failed to find database with internal name {}: {}", internalName, e.getMessage()); - throw new RemoteUnavailableException("Failed to find database: " + e.getMessage(), e); - } - if (!response.getStatusCode().equals(HttpStatus.OK)) { - log.error("Failed to find database with internal name {}: service responded unsuccessful: {}", internalName, response.getStatusCode()); - throw new MetadataServiceException("Failed to find database: service responded unsuccessful: " + response.getStatusCode()); - } - /* body first, then headers next */ - if (response.getBody() == null || response.getBody().length != 1) { - log.error("Failed to find database with internal name {}: body is empty", internalName); - throw new DatabaseNotFoundException("Failed to find database: body is empty"); - } - final List<String> expectedHeaders = List.of("X-Username", "X-Password"); - if (!response.getHeaders().keySet().containsAll(expectedHeaders)) { - log.error("Failed to find all privileged database headers"); - log.debug("expected headers: {}", expectedHeaders); - log.debug("found headers: {}", response.getHeaders().keySet()); - throw new MetadataServiceException("Failed to find all privileged database headers"); - } - return response.getBody()[0]; - } - @Override public PrivilegedTableDto getTableById(Long databaseId, Long id) throws TableNotFoundException, RemoteUnavailableException, MetadataServiceException { @@ -259,34 +223,6 @@ public class MetadataServiceGatewayImpl implements MetadataServiceGateway { return response.getBody(); } - @Override - public UUID getSystemUserId() throws RemoteUnavailableException, UserNotFoundException, - MetadataServiceException { - final ResponseEntity<UserBriefDto[]> response; - try { - response = restTemplate.exchange("/api/user?username=" + gatewayConfig.getSystemUsername(), HttpMethod.GET, HttpEntity.EMPTY, UserBriefDto[].class); - } catch (ResourceAccessException | HttpServerErrorException e) { - log.error("Failed to find user with username {}: {}", gatewayConfig.getSystemUsername(), e.getMessage()); - throw new RemoteUnavailableException("Failed to find user with username " + gatewayConfig.getSystemUsername() + ": " + e.getMessage(), e); - } catch (HttpClientErrorException.NotFound e) { - log.error("Failed to find user with username {}: not found: {}", gatewayConfig.getSystemUsername(), e.getMessage()); - throw new UserNotFoundException("Failed to find user with username " + gatewayConfig.getSystemUsername() + ": " + e.getMessage(), e); - } - if (!response.getStatusCode().equals(HttpStatus.OK)) { - log.error("Failed to find user with username {}: service responded unsuccessful: {}", gatewayConfig.getSystemUsername(), response.getStatusCode()); - throw new MetadataServiceException("Failed to find user with username " + gatewayConfig.getSystemUsername() + ": service responded unsuccessful: " + response.getStatusCode()); - } - if (response.getBody() == null) { - log.error("Failed to find user with username {}: body is empty", gatewayConfig.getSystemUsername()); - throw new MetadataServiceException("Failed to find user with username " + gatewayConfig.getSystemUsername() + ": body is empty"); - } - if (response.getBody().length != 1) { - log.error("Failed to find system user: expected exactly one result but got {}", response.getBody().length); - throw new MetadataServiceException("Failed to find system user: expected exactly one result but got " + response.getBody().length); - } - return response.getBody()[0].getId(); - } - @Override public PrivilegedUserDto getPrivilegedUserById(UUID userId) throws RemoteUnavailableException, UserNotFoundException, MetadataServiceException { diff --git a/dbrepo-data-service/services/src/main/java/at/tuwien/mapper/DataMapper.java b/dbrepo-data-service/services/src/main/java/at/tuwien/mapper/DataMapper.java index b85343cdb8..ccb49288c5 100644 --- a/dbrepo-data-service/services/src/main/java/at/tuwien/mapper/DataMapper.java +++ b/dbrepo-data-service/services/src/main/java/at/tuwien/mapper/DataMapper.java @@ -23,11 +23,6 @@ import at.tuwien.api.user.UserDto; import at.tuwien.config.QueryConfig; import at.tuwien.exception.QueryNotFoundException; import at.tuwien.exception.TableNotFoundException; -import net.sf.jsqlparser.JSQLParserException; -import net.sf.jsqlparser.parser.CCJSqlParserManager; -import net.sf.jsqlparser.schema.Column; -import net.sf.jsqlparser.schema.Table; -import net.sf.jsqlparser.statement.select.*; import org.apache.hadoop.shaded.com.google.common.hash.Hashing; import org.apache.hadoop.shaded.org.apache.commons.io.FileUtils; import org.jetbrains.annotations.NotNull; @@ -38,7 +33,6 @@ import org.mapstruct.Mappings; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.io.StringReader; import java.nio.charset.StandardCharsets; import java.sql.*; import java.time.LocalDateTime; @@ -205,162 +199,6 @@ public interface DataMapper { return view; } - /** - * Parse columns from a SQL statement of a known database. - * - * @param databaseId The database id. - * @param tables The list of tables. - * @param query The SQL statement. - * @return The list of columns. - * @throws JSQLParserException The table/view or column was not found in the database. - */ - default List<ColumnDto> parseColumns(Long databaseId, List<TableDto> tables, String query) throws JSQLParserException { - final List<ColumnDto> columns = new ArrayList<>(); - final CCJSqlParserManager parserRealSql = new CCJSqlParserManager(); - final net.sf.jsqlparser.statement.Statement statement = parserRealSql.parse(new StringReader(query)); - log.trace("parse columns from query: {}", query); - /* bi-directional mapping */ - tables.forEach(table -> table.getColumns() - .forEach(column -> column.setTable(table))); - /* check */ - if (!(statement instanceof Select selectStatement)) { - log.error("Query attempts to update the dataset, not a SELECT statement"); - throw new JSQLParserException("Query attempts to update the dataset"); - } - /* start parsing */ - final PlainSelect ps = (PlainSelect) selectStatement.getSelectBody(); - final List<SelectItem> clauses = ps.getSelectItems(); - log.trace("columns referenced in the from-clause: {}", clauses); - /* Parse all tables */ - final List<FromItem> fromItems = new ArrayList<>(fromItemToFromItems(ps.getFromItem())); - if (ps.getJoins() != null && !ps.getJoins().isEmpty()) { - log.trace("query contains join items: {}", ps.getJoins()); - for (net.sf.jsqlparser.statement.select.Join j : ps.getJoins()) { - if (j.getRightItem() != null) { - fromItems.add(j.getRightItem()); - } - } - } - final List<ColumnDto> allColumns = tables.stream() - .map(TableDto::getColumns) - .flatMap(List::stream) - .toList(); - log.trace("all columns: {}", allColumns.stream().map(ColumnDto::getInternalName).toList()); - log.trace("columns referenced in the from-clause and join-clause(s): {}", clauses); - /* Checking if all columns exist */ - for (SelectItem clause : clauses) { - final SelectExpressionItem item = (SelectExpressionItem) clause; - final Column column = (Column) item.getExpression(); - final String columnName = column.getColumnName().replace("`", ""); - final List<ColumnDto> filteredColumns = allColumns.stream() - .filter(c -> (c.getAlias() != null && c.getAlias().equals(columnName)) || c.getInternalName().equals(columnName)) - .toList(); - String tableOrView = null; - for (Table t : fromItems.stream().map(t -> (net.sf.jsqlparser.schema.Table) t).toList()) { - if (column.getTable() == null) { - /* column does not reference a specific table, find out */ - final List<String> filteredTables = filteredColumns.stream() - .map(c -> c.getTable().getInternalName()) - .filter(table -> fromItems.stream().map(f -> (Table) f).anyMatch(otherTable -> otherTable.getName().replace("`", "").equals(table))) - .toList(); - if (filteredTables.size() != 1) { - log.error("Failed to filter column '{}' to exactly one match: {}", columnName, filteredTables.stream().map(table -> table + "." + columnName).toList()); - throw new JSQLParserException("Failed to filter column '" + columnName + "' to exactly one match"); - } - if (tableMatches(t, filteredTables.get(0))) { - tableOrView = t.getName().replace("`", ""); - break; - } - } - /* column references a specific table */ - final String tableOrAlias = (t.getAlias() != null ? t.getAlias().getName() : column.getTable().getName()) - .replace("`", ""); - if (tableMatches(t, tableOrAlias)) { - tableOrView = t.getName().replace("`", ""); - break; - } - } - if (tableOrView == null) { - log.error("Failed to find table/view {} (with designator {})", column.getTable().getName(), column.getTable().getAlias()); - throw new JSQLParserException("Failed to find table/view " + column.getTable().getName() + " (with alias " + column.getTable().getAlias() + ")"); - } - final String finalTableOrView = tableOrView; - final List<ColumnDto> selectColumns = filteredColumns.stream() - .filter(c -> c.getTable().getInternalName().equals(finalTableOrView)) - .toList(); - final ColumnDto resultColumn; - if (selectColumns.size() != 1) { - if (filteredColumns.size() != 1) { - log.error("Failed to filter column {} to exactly one match: {}", columnName, selectColumns.stream().map(c -> c.getTable().getInternalName() + "." + c.getInternalName()).toList()); - throw new JSQLParserException("Failed to filter column " + columnName + " to exactly one match"); - } - resultColumn = filteredColumns.get(0); - } else { - resultColumn = selectColumns.get(0); - } - if (item.getAlias() != null) { - resultColumn.setAlias(item.getAlias().getName().replace("`", "")); - } - resultColumn.setDatabaseId(databaseId); - resultColumn.setTable(resultColumn.getTable()); - resultColumn.setTableId(resultColumn.getTable().getId()); - log.trace("found column with internal name {} and alias {}", resultColumn.getInternalName(), resultColumn.getAlias()); - columns.add(resultColumn); - } - return columns; - } - - default boolean tableMatches(net.sf.jsqlparser.schema.Table table, String tableOrDesignator) { - final String tableName = table.getName() - .trim() - .replace("`", ""); - if (table.getAlias() == null) { - /* table does not have designator */ - log.trace("table '{}' has no designator", tableName); - return tableName.equals(tableOrDesignator); - } - /* has designator */ - final String designator = table.getAlias() - .getName() - .trim() - .replace("`", ""); - log.trace("table '{}' has designator {}", tableName, designator); - return designator.equals(tableOrDesignator); - } - - default List<FromItem> fromItemToFromItems(FromItem data) throws JSQLParserException { - return fromItemToFromItems(data, 0); - } - - default List<FromItem> fromItemToFromItems(FromItem data, Integer level) throws JSQLParserException { - final List<FromItem> fromItems = new LinkedList<>(); - if (data instanceof net.sf.jsqlparser.schema.Table table) { - fromItems.add(data); - log.trace("from-item {} is of type table: level ~> {}", table.getName(), level); - return fromItems; - } - if (data instanceof SubJoin subJoin) { - log.trace("from-item is of type sub-join: level ~> {}", level); - for (Join join : subJoin.getJoinList()) { - final List<FromItem> tmp = fromItemToFromItems(join.getRightItem(), level + 1); - if (tmp == null) { - log.error("Failed to find right sub-join table: {}", join.getRightItem()); - throw new JSQLParserException("Failed to find right sub-join table"); - } - fromItems.addAll(tmp); - } - final List<FromItem> tmp = fromItemToFromItems(subJoin.getLeft(), level + 1); - if (tmp == null) { - log.error("Failed to find left sub-join table: {}", subJoin.getLeft()); - throw new JSQLParserException("Failed to find left sub-join table"); - } - fromItems.addAll(tmp); - return fromItems; - } - log.warn("unknown from-item {}", data); - return null; - } - default QueryDto resultSetToQueryDto(@NotNull ResultSet data) throws SQLException, QueryNotFoundException { /* note that next() is called outside this mapping function */ return QueryDto.builder() diff --git a/dbrepo-metadata-service/pom.xml b/dbrepo-metadata-service/pom.xml index 56ab43349a..49703fa350 100644 --- a/dbrepo-metadata-service/pom.xml +++ b/dbrepo-metadata-service/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.1.12</version> + <version>3.3.5</version> </parent> <groupId>at.tuwien</groupId> @@ -38,11 +38,11 @@ <properties> <java.version>17</java.version> - <spring-cloud.version>4.0.2</spring-cloud.version> + <spring-cloud.version>4.1.4</spring-cloud.version> <mapstruct.version>1.5.5.Final</mapstruct.version> <rabbitmq.version>5.20.0</rabbitmq.version> <jackson-datatype.version>2.15.0</jackson-datatype.version> - <commons-io.version>2.15.0</commons-io.version> + <commons-io.version>2.17.0</commons-io.version> <commons-validator.version>1.8.0</commons-validator.version> <guava.version>33.0.0-jre</guava.version> <jacoco.version>0.8.12</jacoco.version> @@ -55,6 +55,7 @@ <keycloak.version>21.0.2</keycloak.version> <springdoc-openapi.version>2.3.0</springdoc-openapi.version> <testcontainers.version>1.19.1</testcontainers.version> + <jackson.version>2.15.2</jackson.version> <keycloak-testcontainer.version>3.2.0</keycloak-testcontainer.version> <aws-s3.version>2.25.23</aws-s3.version> <jackson.version>2.15.2</jackson.version> diff --git a/dbrepo-metadata-service/rest-service/src/main/resources/application.yml b/dbrepo-metadata-service/rest-service/src/main/resources/application.yml index 2d79e7cfae..290864eea9 100644 --- a/dbrepo-metadata-service/rest-service/src/main/resources/application.yml +++ b/dbrepo-metadata-service/rest-service/src/main/resources/application.yml @@ -48,21 +48,6 @@ logging: at.tuwien.: "${LOG_LEVEL:info}" org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver: debug dbrepo: - repository-name: "${REPOSITORY_NAME:Database Repository}" - base-url: "${BASE_URL:http://localhost}" - admin-email: "${ADMIN_EMAIL:noreply@example.com}" - deleted-record: "${DELETED_RECORD:persistent}" - granularity: "${GRANULARITY:YYYY-MM-DDThh:mm:ssZ}" - exchangeName: "${BROKER_EXCHANGE_NAME:dbrepo}" - queueName: "${BROKER_QUEUE_NAME:dbrepo}" - connectionTimeout: "${SPARQL_CONNECTION_TIMEOUT:10000}" - s3: - accessKeyId: "${S3_ACCESS_KEY_ID:seaweedfsadmin}" - secretAccessKey: "${S3_SECRET_ACCESS_KEY:seaweedfsadmin}" - bucket: "${S3_BUCKET:dbrepo}" - system: - username: "${SYSTEM_USERNAME:admin}" - password: "${SYSTEM_PASSWORD:admin}" endpoints: analyseService: "${ANALYSE_SERVICE_ENDPOINT:http://analyse-service:8080}" searchService: "${SEARCH_SERVICE_ENDPOINT:http://search-service:8080}" @@ -72,6 +57,13 @@ dbrepo: storageService: "${S3_ENDPOINT:http://storage-service:9000}" rorService: "${ROR_ENDPOINT:https://api.ror.org}" crossRefService: "${CROSSREF_ENDPOINT:http://data.crossref.org}" + s3: + accessKeyId: "${S3_ACCESS_KEY_ID:seaweedfsadmin}" + secretAccessKey: "${S3_SECRET_ACCESS_KEY:seaweedfsadmin}" + bucket: "${S3_BUCKET:dbrepo}" + system: + username: "${SYSTEM_USERNAME:admin}" + password: "${SYSTEM_PASSWORD:admin}" pid: base: "${BASE_URL:http://localhost}/pid/" jwt: @@ -82,3 +74,11 @@ dbrepo: client: "${AUTH_SERVICE_CLIENT:dbrepo-client}" clientSecret: "${AUTH_SERVICE_CLIENT_SECRET:MUwRc7yfXSJwX8AdRMWaQC3Nep1VjwgG}" website: "${BASE_URL:http://localhost}" + repository-name: "${REPOSITORY_NAME:Database Repository}" + base-url: "${BASE_URL:http://localhost}" + admin-email: "${ADMIN_EMAIL:noreply@example.com}" + deleted-record: "${DELETED_RECORD:persistent}" + granularity: "${GRANULARITY:YYYY-MM-DDThh:mm:ssZ}" + exchangeName: "${BROKER_EXCHANGE_NAME:dbrepo}" + queueName: "${BROKER_QUEUE_NAME:dbrepo}" + connectionTimeout: "${SPARQL_CONNECTION_TIMEOUT:10000}" diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mapper/MetadataMapperUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mapper/MetadataMapperUnitTest.java index c849900985..108801e53f 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mapper/MetadataMapperUnitTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mapper/MetadataMapperUnitTest.java @@ -217,7 +217,7 @@ public class MetadataMapperUnitTest extends AbstractUnitTest { final TableDto table0 = response.getTables().get(0); assertEquals(TABLE_1_ID, table0.getId()); assertEquals(TABLE_1_NAME, table0.getName()); - assertEquals(TABLE_1_INTERNALNAME, table0.getInternalName()); + assertEquals(TABLE_1_INTERNAL_NAME, table0.getInternalName()); assertEquals(TABLE_1_DESCRIPTION, table0.getDescription()); assertEquals(DATABASE_1_ID, table0.getTdbid()); assertEquals(USER_1_ID, table0.getCreatedBy()); diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/AuthenticationPrivilegedIntegrationMvcTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/AuthenticationPrivilegedIntegrationMvcTest.java index 6a01ae6fec..22e921f534 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/AuthenticationPrivilegedIntegrationMvcTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/mvc/AuthenticationPrivilegedIntegrationMvcTest.java @@ -166,7 +166,7 @@ public class AuthenticationPrivilegedIntegrationMvcTest extends AbstractUnitTest .andExpect(header().string("X-Port", "" + CONTAINER_1_PORT)) .andExpect(header().string("X-Type", IMAGE_1_JDBC)) .andExpect(header().string("X-Database", DATABASE_1_INTERNALNAME)) - .andExpect(header().string("X-Table", TABLE_1_INTERNALNAME)) + .andExpect(header().string("X-Table", TABLE_1_INTERNAL_NAME)) .andExpect(header().string("Access-Control-Expose-Headers", "X-Username X-Password X-Host X-Port X-Type X-Database X-Table")) .andExpect(status().isOk()); } @@ -184,7 +184,7 @@ public class AuthenticationPrivilegedIntegrationMvcTest extends AbstractUnitTest .andExpect(header().string("X-Port", "" + CONTAINER_1_PORT)) .andExpect(header().string("X-Type", IMAGE_1_JDBC)) .andExpect(header().string("X-Database", DATABASE_1_INTERNALNAME)) - .andExpect(header().string("X-Table", TABLE_1_INTERNALNAME)) + .andExpect(header().string("X-Table", TABLE_1_INTERNAL_NAME)) .andExpect(header().string("Access-Control-Expose-Headers", "X-Username X-Password X-Host X-Port X-Type X-Database X-Table")) .andExpect(status().isOk()); } diff --git a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/TableServiceUnitTest.java b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/TableServiceUnitTest.java index 551a6c350a..01fc883bc8 100644 --- a/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/TableServiceUnitTest.java +++ b/dbrepo-metadata-service/rest-service/src/test/java/at/tuwien/service/TableServiceUnitTest.java @@ -107,7 +107,7 @@ public class TableServiceUnitTest extends AbstractUnitTest { /* test */ assertThrows(DatabaseNotFoundException.class, () -> { - tableService.findByName(DATABASE_3_ID, TABLE_1_INTERNALNAME); + tableService.findByName(DATABASE_3_ID, TABLE_1_INTERNAL_NAME); }); } diff --git a/dbrepo-metadata-service/test/src/main/java/at/tuwien/test/BaseTest.java b/dbrepo-metadata-service/test/src/main/java/at/tuwien/test/BaseTest.java index 30cdff2c40..846251a592 100644 --- a/dbrepo-metadata-service/test/src/main/java/at/tuwien/test/BaseTest.java +++ b/dbrepo-metadata-service/test/src/main/java/at/tuwien/test/BaseTest.java @@ -1416,11 +1416,11 @@ public abstract class BaseTest { public final static Long TABLE_1_ID = 1L; public final static String TABLE_1_NAME = "Weather AUS"; - public final static String TABLE_1_INTERNALNAME = "weather_aus"; + public final static String TABLE_1_INTERNAL_NAME = "weather_aus"; public final static Boolean TABLE_1_VERSIONED = true; public final static Boolean TABLE_1_PROCESSED_CONSTRAINTS = true; public final static String TABLE_1_DESCRIPTION = "Weather in Australia"; - public final static String TABLE_1_QUEUE_NAME = TABLE_1_INTERNALNAME; + public final static String TABLE_1_QUEUE_NAME = TABLE_1_INTERNAL_NAME; public final static String TABLE_1_ROUTING_KEY = "dbrepo\\." + DATABASE_1_ID + "\\." + TABLE_1_ID; public final static Long TABLE_1_DATABASE_ID = DATABASE_1_ID; public final static Long TABLE_1_AVG_ROW_LENGTH = 3L; @@ -1435,7 +1435,7 @@ public abstract class BaseTest { .tdbid(DATABASE_1_ID) .database(null) /* DATABASE_1_PRIVILEGED_DTO */ .created(TABLE_1_CREATED) - .internalName(TABLE_1_INTERNALNAME) + .internalName(TABLE_1_INTERNAL_NAME) .isVersioned(TABLE_1_VERSIONED) .description(TABLE_1_DESCRIPTION) .name(TABLE_1_NAME) @@ -1458,7 +1458,7 @@ public abstract class BaseTest { .tdbid(DATABASE_1_ID) .database(null /* DATABASE_1 */) .created(TABLE_1_CREATED) - .internalName(TABLE_1_INTERNALNAME) + .internalName(TABLE_1_INTERNAL_NAME) .isVersioned(TABLE_1_VERSIONED) .description(TABLE_1_DESCRIPTION) .name(TABLE_1_NAME) @@ -1481,7 +1481,7 @@ public abstract class BaseTest { .id(TABLE_1_ID) .tdbid(DATABASE_1_ID) .created(TABLE_1_CREATED) - .internalName(TABLE_1_INTERNALNAME) + .internalName(TABLE_1_INTERNAL_NAME) .isVersioned(TABLE_1_VERSIONED) .description(TABLE_1_DESCRIPTION) .name(TABLE_1_NAME) @@ -1573,7 +1573,7 @@ public abstract class BaseTest { public final static TableBriefDto TABLE_1_BRIEF_DTO = TableBriefDto.builder() .id(TABLE_1_ID) - .internalName(TABLE_1_INTERNALNAME) + .internalName(TABLE_1_INTERNAL_NAME) .isVersioned(TABLE_1_VERSIONED) .description(TABLE_1_DESCRIPTION) .name(TABLE_1_NAME) -- GitLab