private Integer getTimeout() { return Integer.parseInt(globalWorldFacade.get(DEFAULT_READ_TIMEOUT, "5")); }
private void initDefaultExchanges() { Pattern propertyPattern = Pattern.compile("rabbitmq.exchange\\.(\\d+)\\.(name|type|durable)"); Set<String> keys = new TreeSet<>(this.globalWorldFacade.getKeysStartingWith("rabbitmq.exchange")); Set<String> ids = keys.stream(). map(propertyPattern::matcher). filter(Matcher::matches). map(matcher -> matcher.group(1)). collect(Collectors.toSet()); for (String id : ids) { String name = this.globalWorldFacade.get("rabbitmq.exchange." + id + ".name").or(() -> { throw new IllegalArgumentException("No name specified for predefined exchange: rabbitmq.exchange." + id + ".name"); }); String type = this.globalWorldFacade.get("rabbitmq.exchange." + id + ".type", "direct"); boolean durable = this.globalWorldFacade.getBoolean("rabbitmq.exchange." + id + ".durable", false); declareExchange(name, type, durable); } }
@Override public void statusCodeIs(final int statusCode) { final boolean appendBody = world.getBoolean(CukesOptions.ASSERTS_STATUS_CODE_DISPLAY_BODY, false); final Integer maxSize = world.get(CukesOptions.ASSERTS_STATUS_CODE_MAX_SIZE).transform(new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }).orNull(); final Response response = facade.response(); response.then().statusCode(new StatusCodeMatcher(statusCode, response, appendBody, maxSize)); }
public String getDefaultExchange() { return globalWorldFacade.get(DEFAULT_EXCHANGE_NAME_ATTRIBUTE).orNull(); }
@Override public void statusCodeIs(final int statusCode) { final boolean appendBody = world.getBoolean(CukesOptions.ASSERTS_STATUS_CODE_DISPLAY_BODY, false); final Integer maxSize = world.get(CukesOptions.ASSERTS_STATUS_CODE_MAX_SIZE).transform(new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }).orNull(); final Response response = facade.response(); response.then().statusCode(new StatusCodeMatcher(statusCode, response, appendBody, maxSize)); }
String inflateGroups(String input, Set<String> groups) { String result = input; for (String key : groups) { Optional<String> $value = world.get(key); if ($value.isPresent()) { result = result.replaceAll("\\{\\(" + key + "\\)\\}", $value.get()); } } return result; }
public boolean getBoolean(String key, boolean defaultValue) { return Boolean.valueOf(get(key, Boolean.toString(defaultValue))); }
private void authenticate() { Optional<String> $type = world.get(CukesOptions.AUTH_TYPE); if (!$type.isPresent()) { return; } if ($type.get().equalsIgnoreCase("BASIC")) { authBasic(); } }
@Inject public HttpLoggingPlugin(GlobalWorldFacade world) { this.world = world; logStream = new LoggerPrintStream(getLogger(world.get(LOGGING_LOGGER_NAME, DEFAULT_LOGGER_NAME)), Level.INFO); }
@Inject public HttpLoggingPlugin(GlobalWorldFacade world, RestAssuredConfiguration config) { this.world = world; this.config = config; logStream = new LoggerPrintStream(getLogger(world.get(LOGGING_LOGGER_NAME, DEFAULT_LOGGER_NAME)), Level.INFO); }
public void initConfiguration() { setHost(globalWorldFacade.get(HOST, "localhost")); setPort(Integer.parseInt(globalWorldFacade.get(PORT, "5672"))); setUsername(globalWorldFacade.get(USER, "guest")); setPassword(globalWorldFacade.get(PASSWORD, "password")); setVirtualHost(globalWorldFacade.get(VIRTUAL_HOST, "default")); }
public String normalize(String path) { if (Files.isRelative(path)) { // TODO: Put correct RESOURCE_ROOT String resourceRoot = world.get(CukesOptions.RESOURCES_ROOT, "resources"); return new File(resourceRoot, path).getAbsolutePath(); } return new File(path).getAbsolutePath(); } }
private void authenticate() { Optional<String> $type = world.get(CukesOptions.AUTH_TYPE); if (!$type.isPresent()) { return; } if ($type.get().equalsIgnoreCase("BASIC")) { authBasic(); } }
String getRequestParameter(String grantType) throws UnsupportedEncodingException { Map<String, String> params = GrantType.valueOf(grantType).getParameters(world); com.google.common.base.Optional<String> scope = world.get(OAuthCukesConstants.SCOPE); if (scope.isPresent()) { params.put("scope", scope.get()); } return params.entrySet(). stream(). map(e -> e.getKey() + "=" + e.getValue()). reduce("", (s, s2) -> s + "&" + s2); } }
public void startAllServers() { services.keySet().forEach(serviceName -> { int port = Integer.parseInt(worldFacade.get("http.mock.services." + serviceName + ".port") .or( () -> { throw new CukesRuntimeException("No port provided for mock service " + serviceName + ". Please provide property cukes.http.mock.services." + serviceName + ".port"); })); ClientAndServer server = ClientAndServer.startClientAndServer(port); servers.put(serviceName, server); }); }
public void startAllServers() { services.keySet().forEach(serviceName -> { int port = Integer.parseInt(worldFacade.get("http.mock.services." + serviceName + ".port") .or( () -> { throw new CukesRuntimeException("No port provided for mock service " + serviceName + ". Please provide property cukes.http.mock.services." + serviceName + ".port"); })); ClientAndServer server = ClientAndServer.startClientAndServer(port); servers.put(serviceName, server); }); }
public String processBody(String body) { if (isBodyTemplatesEnabled()) { final Map<String, String> rythmParams = new HashMap<String, String>(); for (String key : world.keys()) { Optional<String> value = world.get(key); if (value.isPresent() && body.contains("@" + key)) rythmParams.put(key, value.get()); } return Rythm.render(body, rythmParams); } return body; } }
public void initRequestMessage() { message = new MessageWrapper(); message.getProperties().contentType(globalWorldFacade.get(CONTENT_TYPE, null)); }