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

Fixed the query test

parent e1da908e
Branches
Tags
2 merge requests!163Relase 1.3.0,!159Large update
...@@ -2338,7 +2338,6 @@ public abstract class BaseTest { ...@@ -2338,7 +2338,6 @@ public abstract class BaseTest {
.createdBy(USER_1_USERNAME) .createdBy(USER_1_USERNAME)
.isPersisted(QUERY_1_PERSISTED) .isPersisted(QUERY_1_PERSISTED)
.executed(QUERY_1_EXECUTION) .executed(QUERY_1_EXECUTION)
.created(QUERY_1_CREATED)
.build(); .build();
public final static QueryDto QUERY_1_DTO = QueryDto.builder() public final static QueryDto QUERY_1_DTO = QueryDto.builder()
...@@ -2349,9 +2348,9 @@ public abstract class BaseTest { ...@@ -2349,9 +2348,9 @@ public abstract class BaseTest {
.queryHash(QUERY_1_QUERY_HASH) .queryHash(QUERY_1_QUERY_HASH)
.resultHash(QUERY_1_RESULT_HASH) .resultHash(QUERY_1_RESULT_HASH)
.created(QUERY_1_CREATED) .created(QUERY_1_CREATED)
.creator(USER_1_DTO)
.execution(QUERY_1_EXECUTION) .execution(QUERY_1_EXECUTION)
.createdBy(USER_1_ID) .createdBy(USER_1_ID)
.creator(USER_1_DTO)
.build(); .build();
public final static QueryBriefDto QUERY_1_BRIEF_DTO = QueryBriefDto.builder() public final static QueryBriefDto QUERY_1_BRIEF_DTO = QueryBriefDto.builder()
......
...@@ -112,8 +112,8 @@ public class StoreServiceIntegrationModifyTest extends BaseUnitTest { ...@@ -112,8 +112,8 @@ public class StoreServiceIntegrationModifyTest extends BaseUnitTest {
} }
@Test @Test
public void insert_same_succeeds() throws UserNotFoundException, QueryStoreException, public void insert_same_succeeds() throws UserNotFoundException, QueryStoreException, DatabaseConnectionException,
DatabaseConnectionException, DatabaseNotFoundException, ImageNotSupportedException, DatabaseNotFoundException, ImageNotSupportedException,
ContainerNotFoundException, SQLException { ContainerNotFoundException, SQLException {
final ExecuteStatementDto request = ExecuteStatementDto.builder() final ExecuteStatementDto request = ExecuteStatementDto.builder()
.statement(QUERY_2_STATEMENT) .statement(QUERY_2_STATEMENT)
...@@ -309,8 +309,8 @@ public class StoreServiceIntegrationModifyTest extends BaseUnitTest { ...@@ -309,8 +309,8 @@ public class StoreServiceIntegrationModifyTest extends BaseUnitTest {
} }
@Test @Test
public void findOne_succeeds() throws UserNotFoundException, QueryStoreException, public void findOne_succeeds() throws UserNotFoundException, QueryStoreException, DatabaseConnectionException,
DatabaseConnectionException, QueryNotFoundException, DatabaseNotFoundException, ImageNotSupportedException, SQLException { QueryNotFoundException, DatabaseNotFoundException, ImageNotSupportedException, SQLException {
/* mock */ /* mock */
when(databaseRepository.findByContainerIdAndDatabaseId(CONTAINER_1_ID, DATABASE_1_ID)) when(databaseRepository.findByContainerIdAndDatabaseId(CONTAINER_1_ID, DATABASE_1_ID))
...@@ -335,7 +335,7 @@ public class StoreServiceIntegrationModifyTest extends BaseUnitTest { ...@@ -335,7 +335,7 @@ public class StoreServiceIntegrationModifyTest extends BaseUnitTest {
} }
@Test @Test
public void findOne_notFound_fails() throws SQLException { public void findOne_notFound_fails() {
final Principal principal = new BasicUserPrincipal(USER_1_USERNAME); final Principal principal = new BasicUserPrincipal(USER_1_USERNAME);
/* mock */ /* mock */
...@@ -350,10 +350,32 @@ public class StoreServiceIntegrationModifyTest extends BaseUnitTest { ...@@ -350,10 +350,32 @@ public class StoreServiceIntegrationModifyTest extends BaseUnitTest {
@Test @Test
public void deleteStaleQueries_succeeds() throws QueryStoreException, ImageNotSupportedException, SQLException { public void deleteStaleQueries_succeeds() throws QueryStoreException, ImageNotSupportedException, SQLException {
final Query queryOk = Query.builder()
.id(QUERY_1_ID)
.query(QUERY_1_STATEMENT)
.queryHash(QUERY_1_QUERY_HASH)
.resultHash(QUERY_1_RESULT_HASH)
.resultNumber(QUERY_1_RESULT_NUMBER)
.created(Instant.now().minus(1, ChronoUnit.HOURS))
.createdBy(USER_1_USERNAME)
.isPersisted(QUERY_1_PERSISTED)
.executed(Instant.now().minus(1, ChronoUnit.HOURS))
.build();
final Query queryDelete = Query.builder()
.id(QUERY_2_ID)
.query(QUERY_2_STATEMENT)
.queryHash(QUERY_2_QUERY_HASH)
.resultHash(QUERY_2_RESULT_HASH)
.resultNumber(QUERY_2_RESULT_NUMBER)
.created(Instant.now().minus(25, ChronoUnit.HOURS))
.createdBy(USER_2_USERNAME)
.isPersisted(QUERY_2_PERSISTED)
.executed(Instant.now().minus(25, ChronoUnit.HOURS))
.build();
/* mock */ /* mock */
MariaDbConfig.insertQueryStore(CONTAINER_1_INTERNALNAME, DATABASE_1_INTERNALNAME, QUERY_1, USER_1_USERNAME); MariaDbConfig.insertQueryStore(CONTAINER_1_INTERNALNAME, DATABASE_1_INTERNALNAME, queryOk, USER_1_USERNAME);
MariaDbConfig.insertQueryStore(CONTAINER_1_INTERNALNAME, DATABASE_1_INTERNALNAME, QUERY_2, USER_1_USERNAME); MariaDbConfig.insertQueryStore(CONTAINER_1_INTERNALNAME, DATABASE_1_INTERNALNAME, queryDelete, USER_1_USERNAME);
when(databaseRepository.findAll()) when(databaseRepository.findAll())
.thenReturn(List.of(DATABASE_1)); .thenReturn(List.of(DATABASE_1));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment