@Test public void invalidQueryGivesDescriptiveErrorMessage() { CommandResult result = gfsh.executeCommand("query --query='this is not a valid query'"); Map<String, String> data = result.getMapFromSection(DataCommandResult.DATA_INFO_SECTION); assertThat(data.get("Result")).isEqualTo("false"); assertThat(data.get("Message")) .startsWith("Query is invalid due to error : <Syntax error in query:"); }
@Test public void queryReturnsNonSelectResult() { CommandResult result = gfsh.executeCommand( "query --query=\"(select c.address from /complexRegion c where c.name = 'name1' limit 1).size\""); Map<String, String> data = result.getMapFromSection(DataCommandResult.DATA_INFO_SECTION); assertThat(data.get("Rows")).isEqualTo("1"); Map<String, List<String>> table = result.getMapFromTableContent(DataCommandResult.QUERY_SECTION); assertThat(table.get("Result")).contains("1"); }
public CommandResultAssert containsOrderedOutput(String dataSectionName, String... expectedOutputs) { LinkedHashMap<String, String> outputMap = ((LinkedHashMap) actual.getCommandResult().getMapFromSection(dataSectionName)); String outputString = outputMap.toString(); int outputIndex = 0; for (int i = 0; i < expectedOutputs.length; i++) { outputIndex = outputString.indexOf(expectedOutputs[i]); if (outputIndex == -1) { Assert.fail("Expected output " + expectedOutputs[i] + " was not found, or isn't in the specified order."); } outputString = outputString.substring(outputIndex); } return this; }
@Test public void queryWithGfshEnvVariables() { gfsh.executeAndAssertThat("set variable --name=DATA_REGION --value=/complexRegion") .statusIsSuccess(); gfsh.executeAndAssertThat("set variable --name=QUERY_LIMIT --value=10").statusIsSuccess(); CommandResult result = gfsh.executeCommand( "query --query='select c.name, c.address from ${DATA_REGION} c limit ${QUERY_LIMIT}'"); Map<String, String> data = result.getMapFromSection(DataCommandResult.DATA_INFO_SECTION); assertThat(data.get("Rows")).isEqualTo("10"); }
@Test public void compositeResultDataStructure() { CompositeResultData result = ResultBuilder.createCompositeResultData(); result.setHeader("Heads"); result.setFooter("Tails"); // build up an example result.addSection().addData("section 0 key", "section 0 value"); result.addSection().addTable().accumulate("table 1 column", "table 1 value"); CommandResult cmdResult = ResultBuilder.buildResult(result); assertThat(cmdResult.getHeader()).isEqualTo("Heads"); assertThat(cmdResult.getFooter()).isEqualTo("Tails"); assertThat(cmdResult.getMapFromSection("0").get("section 0 key")).isEqualTo("section 0 value"); Map<String, List<String>> table = cmdResult.getMapFromTableContent("1", "0"); assertThat(table.get("table 1 column")).contains("table 1 value"); }
.containsAllEntriesOf(clientNewModelResult.getMapFromTableContent("0")); assertThat(clientLegacyResult.getMapFromSection("1")) .containsAllEntriesOf(clientNewModelResult.getMapFromSection("1"));