Skip to content

Commit

Permalink
check if startQuery error is a string/message and use it instead
Browse files Browse the repository at this point in the history
  • Loading branch information
thoniTUB committed Jan 13, 2025
1 parent 4754f71 commit 5c7b2cf
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.bakdata.conquery.io.jetty;

import com.bakdata.conquery.models.error.ConqueryError;
import com.bakdata.conquery.models.error.SimpleErrorInfo;

import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.ext.ExceptionMapper;

import com.bakdata.conquery.models.error.ConqueryError;
import com.bakdata.conquery.models.error.SimpleErrorInfo;

public class ConqueryErrorExceptionMapper implements ExceptionMapper<ConqueryError> {
@Override
public Response toResponse(ConqueryError exception) {
Expand Down
24 changes: 24 additions & 0 deletions cypress/e2e/frontend/test_1_runQuery.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@ describe("Run query", () => {
cy.get('@executionList').find('[data-test-id="project-item-delete-button"]').click();
cy.get('@executionList').contains('Anfrage jetzt löschen').click();
});

it("Check user error message", () => {
cy.get('[data-test-id="right-pane-container"] >div:visible').as("queryEditor");

// Drag concept to editor
cy.contains("MultiConnector").trigger("dragstart").trigger("dragleave");
cy.get("@queryEditor")
.trigger("dragenter")
.trigger("dragover")
.trigger("drop")
.trigger("dragend");

// Switch to secondary id mode
cy.get("@queryEditor").contains("Secondary Id").click()

// Exclude only concept from secondary id to create an invalid query
cy.get("@queryEditor").find('[data-test-id="secondary-id-toggle"]').click()

// Start query
cy.get("@queryEditor").find('[data-test-id="query-runner-button"]').click();

// Check for specific user error message
cy.get('[data-test-id="query-runner"]').contains("Die ausgewählte Analyseebenen konnte in keinem der ausgewählten Konzepten gefunden werden.")
})
});

describe("Reference list", () => {
Expand Down
5 changes: 5 additions & 0 deletions cypress/support/test_data/sid.secondaryId.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"description": "SecondaryId for Dicing",
"label": "Secondary Id",
"name": "sid"
}
4 changes: 2 additions & 2 deletions cypress/support/test_data/table1.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
id,STRING
1,abc
id,sid,STRING
1,a,abc
6 changes: 6 additions & 0 deletions cypress/support/test_data/table1.import.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
"inputType": "STRING",
"operation": "COPY"
},
{
"inputColumn": "sid",
"name": "sid",
"inputType": "STRING",
"operation": "COPY"
},
{
"inputColumn": "STRING",
"name": "STRING",
Expand Down
5 changes: 5 additions & 0 deletions cypress/support/test_data/table1.table.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"name": "id",
"type": "STRING"
},
{
"name": "sid",
"type": "STRING",
"secondaryId": "sid"
},
{
"name": "STRING",
"type": "STRING"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/js/query-runner/QueryRunner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const QueryRunner = ({
);

return (
<Root>
<Root data-test-id="query-runner">
<Left>
<WithTooltip text={buttonTooltip}>
<QueryRunnerButton
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/js/query-runner/QueryRunnerInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ interface PropsT {
const useMessage = (queryRunner: QueryRunnerStateT) => {
const { t } = useTranslation();

if (queryRunner.startQuery.error) {
const error = queryRunner.startQuery.error
if (error) {
// Maybe use type guard here
if (typeof error === 'string' && error.trim().length > 0)
return { type: "error", value: error };
return { type: "error", value: t("queryRunner.startError") };
} else if (queryRunner.stopQuery.error) {
return { type: "error", value: t("queryRunner.stopError") };
Expand Down
1 change: 1 addition & 0 deletions frontend/src/js/standard-query-editor/QueryNodeActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const QueryNodeActions = (props: Props) => {
<RelativeContainer>
<StyledIconButton
icon={faMicroscope}
data-test-id="secondary-id-toggle"
onClick={(e) => {
e.stopPropagation();
props.onToggleSecondaryIdExclude(props.andIdx, props.orIdx);
Expand Down
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.required}</source>
<target>${java.required}</target>
<release>${java.required}</release>
<parameters>true</parameters>
</configuration>
</plugin>
Expand Down
4 changes: 4 additions & 0 deletions scripts/load_e2e_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ echo "Creating mappings"
curl --fail -X POST "$admin_api/datasets/dataset1/internToExtern" -H "$h_ct" -H "$h_auth" -d "@./cypress/support/test_data/mapping.mapping.json"
sleep 3

echo "Creating secondary ids"
curl --fail -X POST "$admin_api/datasets/dataset1/secondaryId" -H "$h_ct" -H "$h_auth" -d "@./cypress/support/test_data/sid.secondaryId.json"
sleep 1

# TODO secondary ID
echo "Creating tables"
for table_json in `ls ./cypress/support/test_data/*.table.json`
Expand Down

0 comments on commit 5c7b2cf

Please sign in to comment.