OptionJuggle { public static OptionSet prepareUoptions(OptionSet options) { boolean hasProxyUri = options.hasProxyUri(); boolean hasUriHost = options.hasUriHost(); boolean hasUriPort = options.hasUriPort(); boolean hasProxyScheme = options.hasProxyScheme(); boolean hasMaxAge = options.hasMaxAge(); boolean hasObserve = options.hasObserve(); OptionSet ret = new OptionSet(); if (hasUriHost) { ret.setUriHost(options.getUriHost()); } if (hasUriPort) { ret.setUriPort(options.getUriPort()); } if (hasMaxAge) { ret.setMaxAge(options.getMaxAge()); } if (hasProxyScheme) { ret.setProxyScheme(options.getProxyScheme()); } if (hasObserve) { ret.setObserve(options.getObserve()); } if (hasProxyUri) { String proxyUri = options.getProxyUri(); proxyUri = proxyUri.replace("coap: proxyUri = proxyUri.replace("coaps: int i = proxyUri.indexOf('/'); if (i >= 0) { proxyUri = proxyUri.substring(0, i); } proxyUri = "coap: ret.setProxyUri(proxyUri); } byte[] oscore = options.getOscore(); if (oscore != null) { ret.setOscore(oscore); } return ret; }  static OptionSet prepareUoptions(OptionSet options); static OptionSet prepareEoptions(OptionSet options); static OptionSet discardEOptions(OptionSet optionSet); static Request setFakeCodeRequest(Request request); static Request setRealCodeRequest(Request request, Code realCode); static Response setFakeCodeResponse(Response response); static Response setRealCodeResponse(Response response, ResponseCode realCode); static OptionSet merge(OptionSet eOptions, OptionSet uOptions);  }
@Test public void testPrepareUOptions() { OptionSet uOptions = new OptionSet(); uOptions.setObserve(observe); uOptions.setAccept(accept); OptionSet trimmed = OptionJuggle.prepareUoptions(uOptions); assertEquals(observe, trimmed.getObserve()); assertEquals(-1, trimmed.getAccept()); }