-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #155 from marklogic/feature/test-fix
Improving error message for when max value query fails
- Loading branch information
Showing
4 changed files
with
42 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/test/java/com/marklogic/kafka/connect/source/QueryHandlerUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.marklogic.kafka.connect.source; | ||
|
||
import com.marklogic.client.io.StringHandle; | ||
import com.marklogic.client.row.RawQueryDSLPlan; | ||
import com.marklogic.client.row.RowManager; | ||
import com.marklogic.kafka.connect.MarkLogicConnectorException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class QueryHandlerUtilTest extends AbstractIntegrationSourceTest { | ||
|
||
@Test | ||
void invalidMaxValueQuery() { | ||
RowManager rowManager = getDatabaseClient().newRowManager(); | ||
final String invalidDsl = "This should fail"; | ||
RawQueryDSLPlan invalidQuery = rowManager.newRawQueryDSLPlan(new StringHandle(invalidDsl)); | ||
|
||
MarkLogicConnectorException ex = assertThrows(MarkLogicConnectorException.class, | ||
() -> QueryHandlerUtil.executeMaxValuePlan(rowManager, invalidQuery, 0, invalidDsl)); | ||
|
||
assertTrue(ex.getMessage().startsWith("Unable to get max constraint value; query: This should fail"), | ||
"If either our max value query has a bug in it, or the server has a bug in it with processing our max " + | ||
"value query, an exception should be thrown that informs the user that the max value query failed " + | ||
"along with what the query was"); | ||
} | ||
} |