@Override public String toString() { return get().toString(); }
@Override public String toString() { return get().toString(); }
/** * Check if the passed headers (specifically Accept) prefer * data in JSON format. * * @return true if passed headers prefer data in JSON format. */ static boolean requestsJsonData(RequestHeaders headers) { Optional<MediaType> mediaType = headers.bestAccepted(MediaType.TEXT_PLAIN, MediaType.APPLICATION_JSON); boolean requestsJson = mediaType.isPresent() && mediaType.get().equals(MediaType.APPLICATION_JSON); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine("Generating metrics for media type " + mediaType.toString() + ". requestsJson=" + requestsJson); } return requestsJson; }
public FunctionInvoker createFunctionInvoker(Signature signature, Optional<InvocationConvention> invocationConvention) { ScalarFunctionImplementation scalarFunctionImplementation = functionRegistry.getScalarFunctionImplementation(signature); for (ScalarImplementationChoice choice : scalarFunctionImplementation.getAllChoices()) { if (checkChoice(choice.getArgumentProperties(), choice.isNullable(), choice.hasSession(), invocationConvention)) { return new FunctionInvoker(choice.getMethodHandle()); } } checkState(invocationConvention.isPresent()); throw new PrestoException(FUNCTION_NOT_FOUND, format("Dependent function implementation (%s) with convention (%s) is not available", signature, invocationConvention.toString())); }
@GET @Path("/get") public String bucket() { return client.get("hello").toString(); }
@GET @Path("/get") public String bucket() { return client.get("hello").toString(); }
@GET @Path("/get") public String bucket() { return client.get("hello") .toString(); }
@GET @Path("/get") public String bucket() { return client.get("hello") .toString(); }
@GET @Path("/get") public String bucket() { return client.get("hello") .toString(); }
@Test public void testSelectSinkProperties() { final String simpleQuery = "create stream s1 with (timestamp='orderid', partitions = 3) as select " + "col1, col2" + " from orders where col2 is null and col3 is not null or (col3*col2 = " + "12);"; final Statement statement = KSQL_PARSER.buildAst(simpleQuery, metaStore).get(0).getStatement(); final StatementRewriter statementRewriter = new StatementRewriter(); final Statement rewrittenStatement = (Statement) statementRewriter.process(statement, null); assertThat(rewrittenStatement, instanceOf(CreateStreamAsSelect.class)); final CreateStreamAsSelect createStreamAsSelect = (CreateStreamAsSelect) rewrittenStatement; assertThat(createStreamAsSelect.getQuery().getQueryBody() , instanceOf(QuerySpecification.class)); final QuerySpecification querySpecification = (QuerySpecification) createStreamAsSelect.getQuery().getQueryBody(); assertThat(querySpecification.getWhere().toString(), equalTo("Optional[(((ORDERS.COL2 IS NULL) AND (ORDERS.COL3 IS NOT NULL)) OR ((ORDERS.COL3 * ORDERS.COL2) = 12))]")); }
@Test public void testSelectSinkProperties() { final String simpleQuery = "create stream s1 with (timestamp='orderid', partitions = 3) as select " + "col1, col2" + " from orders where col2 is null and col3 is not null or (col3*col2 = " + "12);"; final Statement statement = KSQL_PARSER.buildAst(simpleQuery, metaStore).get(0).getStatement(); Assert.assertTrue("testSelectTumblingWindow failed.", statement instanceof CreateStreamAsSelect); final CreateStreamAsSelect createStreamAsSelect = (CreateStreamAsSelect) statement; Assert.assertTrue("testSelectTumblingWindow failed.", createStreamAsSelect.getQuery().getQueryBody() instanceof QuerySpecification); final QuerySpecification querySpecification = (QuerySpecification) createStreamAsSelect.getQuery().getQueryBody(); Assert.assertTrue(querySpecification.getWhere().toString().equalsIgnoreCase("Optional[(((ORDERS.COL2 IS NULL) AND (ORDERS.COL3 IS NOT NULL)) OR ((ORDERS.COL3 * ORDERS.COL2) = 12))]")); }
@Test public void testContextGetsBinding() { try { h.prepareBatch("insert into something (id, name) values (:id, :name)") .bind("id", 0) .bind("name", "alice") .add() .bind("id", 0) .bind("name", "bob") .add() .execute(); fail("expected exception"); } catch (UnableToExecuteStatementException e) { final StatementContext ctx = e.getStatementContext(); assertThat(ctx.getBinding().findForName("name", ctx).toString()).contains("bob"); } }
@Override public String toString() { return documentId.toString(); } }
@Override public String toString() { return alwaysPresentValue.toString(); }
@Test public void testWithFunction() { StellarResult result = command.execute("?TO_STRING", executor); // validate the result assertTrue(result.isSuccess()); assertTrue(result.getValue().isPresent()); // validate that we have some sort of doc string assertTrue(result.getValue().toString().length() > 0); }
@Override public void describeTo(Description description) { description.appendText(Optional.of(content).toString()); } };
public static String toString(IdRange[] ranges) { return Optional.ofNullable(ranges) .map(ImmutableList::copyOf) .toString(); }
@Override public String toString() { String body; try { body = getBody().toString(); } catch (IOException e) { body = "<unknown>"; } return String.format( "Response (code: %d, message: %s, headers: %s, body: %s)", getCode(), getMessage(), getHeaders(), body); }
public FunctionInvoker createFunctionInvoker(Signature signature, Optional<InvocationConvention> invocationConvention) { ScalarFunctionImplementation scalarFunctionImplementation = functionRegistry.getScalarFunctionImplementation(signature); for (ScalarImplementationChoice choice : scalarFunctionImplementation.getAllChoices()) { if (checkChoice(choice.getArgumentProperties(), choice.isNullable(), choice.hasSession(), invocationConvention)) { return new FunctionInvoker(choice.getMethodHandle()); } } checkState(invocationConvention.isPresent()); throw new PrestoException(FUNCTION_NOT_FOUND, format("Dependent function implementation (%s) with convention (%s) is not available", signature, invocationConvention.toString())); }
public @Test void healthCheckAfterInitBeforePrepare() { PRStatus status = origin.getRepo().command(PRHealthCheckOp.class).setId(request.getId()) .call(); assertNotNull(status); assertEquals(request, status.getRequest()); Optional<ObjectId> mergeCommit = status.getMergeCommit(); assertFalse(mergeCommit.toString(), mergeCommit.isPresent()); // PR was just inited, not prepared, so it's behind the remote branch assertEquals(3, status.getCommitsBehindRemoteBranch()); assertEquals(0, status.getCommitsBehindTargetBranch()); assertEquals(0, status.getNumConflicts()); }