target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void testOnTrigger() throws InitializationException { final String metricsUrl = "http: final String applicationId = "nifi"; final String hostName = "localhost"; final String jobName = "nifi_reporting_job"; final boolean jvmMetrics = true; final boolean authentication = false; final Client client = Mockito.... | @Override public void onTrigger(final ReportingContext context) { final String metricsCollectorUrl = context.getProperty(METRICS_COLLECTOR_URL) .evaluateAttributeExpressions().getValue() .replace("http: final String applicationId = context.getProperty(APPLICATION_ID).evaluateAttributeExpressions().getValue(); final Str... | PrometheusReportingTask extends AbstractReportingTask { @Override public void onTrigger(final ReportingContext context) { final String metricsCollectorUrl = context.getProperty(METRICS_COLLECTOR_URL) .evaluateAttributeExpressions().getValue() .replace("http: final String applicationId = context.getProperty(APPLICATION_... | PrometheusReportingTask extends AbstractReportingTask { @Override public void onTrigger(final ReportingContext context) { final String metricsCollectorUrl = context.getProperty(METRICS_COLLECTOR_URL) .evaluateAttributeExpressions().getValue() .replace("http: final String applicationId = context.getProperty(APPLICATION_... | PrometheusReportingTask extends AbstractReportingTask { @Override public void onTrigger(final ReportingContext context) { final String metricsCollectorUrl = context.getProperty(METRICS_COLLECTOR_URL) .evaluateAttributeExpressions().getValue() .replace("http: final String applicationId = context.getProperty(APPLICATION_... | PrometheusReportingTask extends AbstractReportingTask { @Override public void onTrigger(final ReportingContext context) { final String metricsCollectorUrl = context.getProperty(METRICS_COLLECTOR_URL) .evaluateAttributeExpressions().getValue() .replace("http: final String applicationId = context.getProperty(APPLICATION_... |
@Test public void testName() { assertThat(factory.name()).isEqualTo("kafka"); } | @Override public String name() { return "kafka"; } | KafkaSinkFactory implements SinkFactory { @Override public String name() { return "kafka"; } } | KafkaSinkFactory implements SinkFactory { @Override public String name() { return "kafka"; } } | KafkaSinkFactory implements SinkFactory { @Override public String name() { return "kafka"; } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } | KafkaSinkFactory implements SinkFactory { @Override public String name() { return "kafka"; } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } |
@Test(expected = IllegalArgumentException.class) public void testTransformationWithNotAnnotatedParameter() throws NoSuchMethodException { InvalidBecauseOfBadParams test = new InvalidBecauseOfBadParams(); Method method = test.getClass().getMethod("trans", Source.class); ReflectionHelper.invokeTransformationMethod(test, ... | public static void invokeTransformationMethod(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Object> values = getParameterFromTransformationMethod(method); try { Class<?> returnType = method.getReturnType(); Outbound outbound = method.getAnnotation(Outbound.class); if (ret... | ReflectionHelper { public static void invokeTransformationMethod(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Object> values = getParameterFromTransformationMethod(method); try { Class<?> returnType = method.getReturnType(); Outbound outbound = method.getAnnotation(Outbo... | ReflectionHelper { public static void invokeTransformationMethod(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Object> values = getParameterFromTransformationMethod(method); try { Class<?> returnType = method.getReturnType(); Outbound outbound = method.getAnnotation(Outbo... | ReflectionHelper { public static void invokeTransformationMethod(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Object> values = getParameterFromTransformationMethod(method); try { Class<?> returnType = method.getReturnType(); Outbound outbound = method.getAnnotation(Outbo... | ReflectionHelper { public static void invokeTransformationMethod(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Object> values = getParameterFromTransformationMethod(method); try { Class<?> returnType = method.getReturnType(); Outbound outbound = method.getAnnotation(Outbo... |
@Test public void testGettingAMissingSink() { FluidRegistry.register("my-sink", Sink.list()); Sink<Object> sink = ReflectionHelper.getSinkOrFail("my-sink"); assertThat(sink).isNotNull(); try { ReflectionHelper.getSinkOrFail("missing"); fail("The sink should be missing"); } catch (IllegalArgumentException e) { } } | static Sink<Object> getSinkOrFail(String name) { Sink<Object> sink = FluidRegistry.sink(Objects.requireNonNull(name)); if (sink == null) { throw new IllegalArgumentException("Unable to find the sink " + name); } return sink; } | ReflectionHelper { static Sink<Object> getSinkOrFail(String name) { Sink<Object> sink = FluidRegistry.sink(Objects.requireNonNull(name)); if (sink == null) { throw new IllegalArgumentException("Unable to find the sink " + name); } return sink; } } | ReflectionHelper { static Sink<Object> getSinkOrFail(String name) { Sink<Object> sink = FluidRegistry.sink(Objects.requireNonNull(name)); if (sink == null) { throw new IllegalArgumentException("Unable to find the sink " + name); } return sink; } private ReflectionHelper(); } | ReflectionHelper { static Sink<Object> getSinkOrFail(String name) { Sink<Object> sink = FluidRegistry.sink(Objects.requireNonNull(name)); if (sink == null) { throw new IllegalArgumentException("Unable to find the sink " + name); } return sink; } private ReflectionHelper(); static void set(Object mediator, Field field,... | ReflectionHelper { static Sink<Object> getSinkOrFail(String name) { Sink<Object> sink = FluidRegistry.sink(Objects.requireNonNull(name)); if (sink == null) { throw new IllegalArgumentException("Unable to find the sink " + name); } return sink; } private ReflectionHelper(); static void set(Object mediator, Field field,... |
@Test public void testGettingAMissingSource() { FluidRegistry.register("my-source", Source.empty()); Source<Object> source = ReflectionHelper.getSourceOrFail("my-source"); assertThat(source).isNotNull(); try { ReflectionHelper.getSourceOrFail("missing"); fail("The source should be missing"); } catch (IllegalArgumentExc... | static Source<Object> getSourceOrFail(String name) { Source<Object> src = FluidRegistry.source(Objects.requireNonNull(name)); if (src == null) { throw new IllegalArgumentException("Unable to find the source " + name); } return src; } | ReflectionHelper { static Source<Object> getSourceOrFail(String name) { Source<Object> src = FluidRegistry.source(Objects.requireNonNull(name)); if (src == null) { throw new IllegalArgumentException("Unable to find the source " + name); } return src; } } | ReflectionHelper { static Source<Object> getSourceOrFail(String name) { Source<Object> src = FluidRegistry.source(Objects.requireNonNull(name)); if (src == null) { throw new IllegalArgumentException("Unable to find the source " + name); } return src; } private ReflectionHelper(); } | ReflectionHelper { static Source<Object> getSourceOrFail(String name) { Source<Object> src = FluidRegistry.source(Objects.requireNonNull(name)); if (src == null) { throw new IllegalArgumentException("Unable to find the source " + name); } return src; } private ReflectionHelper(); static void set(Object mediator, Field... | ReflectionHelper { static Source<Object> getSourceOrFail(String name) { Source<Object> src = FluidRegistry.source(Objects.requireNonNull(name)); if (src == null) { throw new IllegalArgumentException("Unable to find the source " + name); } return src; } private ReflectionHelper(); static void set(Object mediator, Field... |
@Test(expected = NullPointerException.class) public void testRegistrationOfSinkWithNullName() { Sink<String> discard = Sink.discard(); FluidRegistry.register(null, discard); } | public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } | FluidRegistry { public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } } | FluidRegistry { public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } private FluidRegistry(); } | FluidRegistry { public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } private FluidRegistry(); static synchronized void initialize(Vertx vertx, FluidConfig config); static void reset(); static synchronized void register... | FluidRegistry { public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } private FluidRegistry(); static synchronized void initialize(Vertx vertx, FluidConfig config); static void reset(); static synchronized void register... |
@Test(expected = NullPointerException.class) public void testRegistrationOfSourceWithNullName() { Source<String> source = Source.empty(); FluidRegistry.register(null, source); } | public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } | FluidRegistry { public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } } | FluidRegistry { public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } private FluidRegistry(); } | FluidRegistry { public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } private FluidRegistry(); static synchronized void initialize(Vertx vertx, FluidConfig config); static void reset(); static synchronized void register... | FluidRegistry { public static synchronized <T> void register(Source<T> source) { sources.put(Objects.requireNonNull(source.name(), NAME_NOT_PROVIDED_MESSAGE), source); } private FluidRegistry(); static synchronized void initialize(Vertx vertx, FluidConfig config); static void reset(); static synchronized void register... |
@Test public void testInitialize() { Fluid fluid = Fluid.create(); assertThat(FluidRegistry.source("unknown")).isNull(); assertThat(FluidRegistry.sink("unknown")).isNull(); fluid.vertx().close(); } | public static synchronized void initialize(Vertx vertx, FluidConfig config) { sinks.putAll(SourceAndSinkBuilder.createSinksFromConfiguration(vertx, config)); sources.putAll(SourceAndSinkBuilder.createSourcesFromConfiguration(vertx, config)); } | FluidRegistry { public static synchronized void initialize(Vertx vertx, FluidConfig config) { sinks.putAll(SourceAndSinkBuilder.createSinksFromConfiguration(vertx, config)); sources.putAll(SourceAndSinkBuilder.createSourcesFromConfiguration(vertx, config)); } } | FluidRegistry { public static synchronized void initialize(Vertx vertx, FluidConfig config) { sinks.putAll(SourceAndSinkBuilder.createSinksFromConfiguration(vertx, config)); sources.putAll(SourceAndSinkBuilder.createSourcesFromConfiguration(vertx, config)); } private FluidRegistry(); } | FluidRegistry { public static synchronized void initialize(Vertx vertx, FluidConfig config) { sinks.putAll(SourceAndSinkBuilder.createSinksFromConfiguration(vertx, config)); sources.putAll(SourceAndSinkBuilder.createSourcesFromConfiguration(vertx, config)); } private FluidRegistry(); static synchronized void initializ... | FluidRegistry { public static synchronized void initialize(Vertx vertx, FluidConfig config) { sinks.putAll(SourceAndSinkBuilder.createSinksFromConfiguration(vertx, config)); sources.putAll(SourceAndSinkBuilder.createSourcesFromConfiguration(vertx, config)); } private FluidRegistry(); static synchronized void initializ... |
@SuppressWarnings("unchecked") @Test public void loadSourceTest() { Map<String, Source> sources = SourceAndSinkBuilder.createSourcesFromConfiguration(vertx, fluid.getConfig()); assertThat(sources).hasSize(2); Source<String> source1 = sources.get("source1"); assertThat(source1).isNotNull(); Source<Integer> source2 = sou... | public static Map<String, Source> createSourcesFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Source> map = new HashMap<>(); Optional<Config> sources = config.getConfig("sources"); if (sources.isPresent()) { Iterator<String> names = sources.get().names(); while (names.hasNext()) { String name = names.... | SourceAndSinkBuilder { public static Map<String, Source> createSourcesFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Source> map = new HashMap<>(); Optional<Config> sources = config.getConfig("sources"); if (sources.isPresent()) { Iterator<String> names = sources.get().names(); while (names.hasNext())... | SourceAndSinkBuilder { public static Map<String, Source> createSourcesFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Source> map = new HashMap<>(); Optional<Config> sources = config.getConfig("sources"); if (sources.isPresent()) { Iterator<String> names = sources.get().names(); while (names.hasNext())... | SourceAndSinkBuilder { public static Map<String, Source> createSourcesFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Source> map = new HashMap<>(); Optional<Config> sources = config.getConfig("sources"); if (sources.isPresent()) { Iterator<String> names = sources.get().names(); while (names.hasNext())... | SourceAndSinkBuilder { public static Map<String, Source> createSourcesFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Source> map = new HashMap<>(); Optional<Config> sources = config.getConfig("sources"); if (sources.isPresent()) { Iterator<String> names = sources.get().names(); while (names.hasNext())... |
@SuppressWarnings("unchecked") @Test public void loadSinkTest() { Map<String, Sink> sinks = SourceAndSinkBuilder.createSinksFromConfiguration(vertx, fluid.getConfig()); assertThat(sinks).hasSize(2); Sink<String> sink1 = sinks.get("sink1"); assertThat(sink1).isNotNull().isInstanceOf(ListSink.class); Sink<Integer> sink2 ... | public static Map<String, Sink> createSinksFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Sink> map = new HashMap<>(); Optional<Config> sinks = config.getConfig("sinks"); if (sinks.isPresent()) { Iterator<String> names = sinks.get().names(); while (names.hasNext()) { String name = names.next(); LOGGER... | SourceAndSinkBuilder { public static Map<String, Sink> createSinksFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Sink> map = new HashMap<>(); Optional<Config> sinks = config.getConfig("sinks"); if (sinks.isPresent()) { Iterator<String> names = sinks.get().names(); while (names.hasNext()) { String name... | SourceAndSinkBuilder { public static Map<String, Sink> createSinksFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Sink> map = new HashMap<>(); Optional<Config> sinks = config.getConfig("sinks"); if (sinks.isPresent()) { Iterator<String> names = sinks.get().names(); while (names.hasNext()) { String name... | SourceAndSinkBuilder { public static Map<String, Sink> createSinksFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Sink> map = new HashMap<>(); Optional<Config> sinks = config.getConfig("sinks"); if (sinks.isPresent()) { Iterator<String> names = sinks.get().names(); while (names.hasNext()) { String name... | SourceAndSinkBuilder { public static Map<String, Sink> createSinksFromConfiguration(Vertx vertx, FluidConfig config) { Map<String, Sink> map = new HashMap<>(); Optional<Config> sinks = config.getConfig("sinks"); if (sinks.isPresent()) { Iterator<String> names = sinks.get().names(); while (names.hasNext()) { String name... |
@Test public void shouldGetRequiredAddress() { assertThat(address(messageWithCommonHeaders)).isEqualTo("address"); } | public static String address(Message message) { return (String) message.get(ADDRESS); } | CommonHeaders { public static String address(Message message) { return (String) message.get(ADDRESS); } } | CommonHeaders { public static String address(Message message) { return (String) message.get(ADDRESS); } private CommonHeaders(); } | CommonHeaders { public static String address(Message message) { return (String) message.get(ADDRESS); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); static String address(Message message); @Su... | CommonHeaders { public static String address(Message message) { return (String) message.get(ADDRESS); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); static String address(Message message); @Su... |
@Test public void shouldHandleEmptyAddress() { assertThat(addressOpt(messageWithoutCommonHeaders)).isEmpty(); } | @SuppressWarnings("unchecked") public static Optional<String> addressOpt(Message message) { return message.getOpt(ADDRESS); } | CommonHeaders { @SuppressWarnings("unchecked") public static Optional<String> addressOpt(Message message) { return message.getOpt(ADDRESS); } } | CommonHeaders { @SuppressWarnings("unchecked") public static Optional<String> addressOpt(Message message) { return message.getOpt(ADDRESS); } private CommonHeaders(); } | CommonHeaders { @SuppressWarnings("unchecked") public static Optional<String> addressOpt(Message message) { return message.getOpt(ADDRESS); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); stati... | CommonHeaders { @SuppressWarnings("unchecked") public static Optional<String> addressOpt(Message message) { return message.getOpt(ADDRESS); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); stati... |
@Test(expected = ConfigException.class) public void testCreationWithoutParameter() { factory.create(vertx, null, new Config(NullNode.getInstance())); } | @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } | KafkaSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } } | KafkaSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } } | KafkaSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } | KafkaSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } |
@Test public void shouldGetRequiredKey() { assertThat(key(messageWithCommonHeaders)).isEqualTo("key"); } | public static String key(Message message) { return (String) message.get(KEY); } | CommonHeaders { public static String key(Message message) { return (String) message.get(KEY); } } | CommonHeaders { public static String key(Message message) { return (String) message.get(KEY); } private CommonHeaders(); } | CommonHeaders { public static String key(Message message) { return (String) message.get(KEY); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); static String address(Message message); @SuppressWa... | CommonHeaders { public static String key(Message message) { return (String) message.get(KEY); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); static String address(Message message); @SuppressWa... |
@Test public void shouldHandleEmptyKey() { assertThat(keyOpt(messageWithoutCommonHeaders)).isEmpty(); } | @SuppressWarnings("unchecked") public static Optional<String> keyOpt(Message message) { return message.getOpt(KEY); } | CommonHeaders { @SuppressWarnings("unchecked") public static Optional<String> keyOpt(Message message) { return message.getOpt(KEY); } } | CommonHeaders { @SuppressWarnings("unchecked") public static Optional<String> keyOpt(Message message) { return message.getOpt(KEY); } private CommonHeaders(); } | CommonHeaders { @SuppressWarnings("unchecked") public static Optional<String> keyOpt(Message message) { return message.getOpt(KEY); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); static String... | CommonHeaders { @SuppressWarnings("unchecked") public static Optional<String> keyOpt(Message message) { return message.getOpt(KEY); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); static String... |
@Test public void shouldGetRequiredOriginalData() { assertThat(CommonHeaders.<String>original(messageWithCommonHeaders)).isEqualTo("original"); } | @SuppressWarnings("unchecked") public static <T> T original(Message message) { return (T) message.get(ORIGINAL); } | CommonHeaders { @SuppressWarnings("unchecked") public static <T> T original(Message message) { return (T) message.get(ORIGINAL); } } | CommonHeaders { @SuppressWarnings("unchecked") public static <T> T original(Message message) { return (T) message.get(ORIGINAL); } private CommonHeaders(); } | CommonHeaders { @SuppressWarnings("unchecked") public static <T> T original(Message message) { return (T) message.get(ORIGINAL); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); static String ad... | CommonHeaders { @SuppressWarnings("unchecked") public static <T> T original(Message message) { return (T) message.get(ORIGINAL); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); static String ad... |
@Test public void shouldHandleEmptyOriginal() { assertThat(originalOpt(messageWithoutCommonHeaders)).isEmpty(); } | @SuppressWarnings("unchecked") public static <T> Optional<T> originalOpt(Message message) { return message.getOpt(ORIGINAL); } | CommonHeaders { @SuppressWarnings("unchecked") public static <T> Optional<T> originalOpt(Message message) { return message.getOpt(ORIGINAL); } } | CommonHeaders { @SuppressWarnings("unchecked") public static <T> Optional<T> originalOpt(Message message) { return message.getOpt(ORIGINAL); } private CommonHeaders(); } | CommonHeaders { @SuppressWarnings("unchecked") public static <T> Optional<T> originalOpt(Message message) { return message.getOpt(ORIGINAL); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); stat... | CommonHeaders { @SuppressWarnings("unchecked") public static <T> Optional<T> originalOpt(Message message) { return message.getOpt(ORIGINAL); } private CommonHeaders(); @SuppressWarnings("unchecked") static T original(Message message); @SuppressWarnings("unchecked") static Optional<T> originalOpt(Message message); stat... |
@Test(expected = IllegalArgumentException.class) public void testNullName() { Source.from("a", "b", "c").named(null); } | @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } | DefaultSource implements Source<T> { @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } } | DefaultSource implements Source<T> { @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> ... | DefaultSource implements Source<T> { @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> ... | DefaultSource implements Source<T> { @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> ... |
@Test(expected = IllegalArgumentException.class) public void testBlankName() { Source.from("a", "b", "c").named(" "); } | @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } | DefaultSource implements Source<T> { @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } } | DefaultSource implements Source<T> { @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> ... | DefaultSource implements Source<T> { @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> ... | DefaultSource implements Source<T> { @Override public Source<T> named(String name) { if (Strings.isBlank(name)) { throw new IllegalArgumentException("The name cannot be `null` or blank"); } return new DefaultSource<>(flow, name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> ... |
@Test public void testOrElse() { Source<String> source = Source.from("a", "b", "c") .named("my source"); Source<String> empty = Source.<String>empty().named("empty"); Source<String> another = Source.from("d", "e", "f"); ListSink<String> sink = Sink.list(); source.orElse(another).to(sink); assertThat(sink.values()).cont... | @Override public Source<T> orElse(Source<T> alt) { Objects.requireNonNull(alt, "The alternative source must not be `null`"); return new DefaultSource<>(Flowable.fromPublisher(flow).switchIfEmpty(alt), name, attributes); } | DefaultSource implements Source<T> { @Override public Source<T> orElse(Source<T> alt) { Objects.requireNonNull(alt, "The alternative source must not be `null`"); return new DefaultSource<>(Flowable.fromPublisher(flow).switchIfEmpty(alt), name, attributes); } } | DefaultSource implements Source<T> { @Override public Source<T> orElse(Source<T> alt) { Objects.requireNonNull(alt, "The alternative source must not be `null`"); return new DefaultSource<>(Flowable.fromPublisher(flow).switchIfEmpty(alt), name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<S... | DefaultSource implements Source<T> { @Override public Source<T> orElse(Source<T> alt) { Objects.requireNonNull(alt, "The alternative source must not be `null`"); return new DefaultSource<>(Flowable.fromPublisher(flow).switchIfEmpty(alt), name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<S... | DefaultSource implements Source<T> { @Override public Source<T> orElse(Source<T> alt) { Objects.requireNonNull(alt, "The alternative source must not be `null`"); return new DefaultSource<>(Flowable.fromPublisher(flow).switchIfEmpty(alt), name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<S... |
@Test public void testFlatMap() { ListSink<Integer> sink = Sink.list(); Random random = new Random(); Source.from(1, 2, 3, 4, 5) .flatMap(i -> Flowable.fromArray(i, i).delay(random.nextInt(10), TimeUnit.MILLISECONDS)) .to(sink); await().until(() -> sink.values().size() == 10); assertThat(sink.values()).contains(1, 1, 2... | @Override public <X> Source<X> flatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).flatMap(mapper::apply), name, attributes); } | DefaultSource implements Source<T> { @Override public <X> Source<X> flatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).flatMap(mapper::apply), name, attributes); } } | DefaultSource implements Source<T> { @Override public <X> Source<X> flatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).flatMap(mapper::apply), name, attributes); } DefaultSource(Publisher<... | DefaultSource implements Source<T> { @Override public <X> Source<X> flatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).flatMap(mapper::apply), name, attributes); } DefaultSource(Publisher<... | DefaultSource implements Source<T> { @Override public <X> Source<X> flatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).flatMap(mapper::apply), name, attributes); } DefaultSource(Publisher<... |
@Test public void testConcatMap() { ListSink<Integer> sink = Sink.list(); Random random = new Random(); Source.from(1, 2, 3, 4, 5) .concatMap(i -> Flowable.fromArray(i, i).delay(random.nextInt(10), TimeUnit.MILLISECONDS)) .to(sink); await().until(() -> sink.values().size() == 10); assertThat(sink.values()).containsExac... | @Override public <X> Source<X> concatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).concatMap(mapper::apply), name, attributes); } | DefaultSource implements Source<T> { @Override public <X> Source<X> concatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).concatMap(mapper::apply), name, attributes); } } | DefaultSource implements Source<T> { @Override public <X> Source<X> concatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).concatMap(mapper::apply), name, attributes); } DefaultSource(Publis... | DefaultSource implements Source<T> { @Override public <X> Source<X> concatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).concatMap(mapper::apply), name, attributes); } DefaultSource(Publis... | DefaultSource implements Source<T> { @Override public <X> Source<X> concatMap(Function<Message<T>, Publisher<Message<X>>> mapper) { Objects.requireNonNull(mapper, FUNCTION_CANNOT_BE_NULL_MESSAGE); return new DefaultSource<>(Flowable.fromPublisher(flow).concatMap(mapper::apply), name, attributes); } DefaultSource(Publis... |
@Test public void testCompose() { ListSink<Integer> list = Sink.list(); Source.from(1, 2, 3, 4, 5) .composeFlowable(flow -> flow.map(Message::payload).map(i -> i + 1).map(Message::new)) .to(list); assertThat(list.values()).containsExactly(2, 3, 4, 5, 6); } | @Override public <X> Source<X> compose(Function<Publisher<Message<T>>, Publisher<Message<X>>> mapper) { return new DefaultSource<>(asFlowable().compose(mapper::apply), name, attributes); } | DefaultSource implements Source<T> { @Override public <X> Source<X> compose(Function<Publisher<Message<T>>, Publisher<Message<X>>> mapper) { return new DefaultSource<>(asFlowable().compose(mapper::apply), name, attributes); } } | DefaultSource implements Source<T> { @Override public <X> Source<X> compose(Function<Publisher<Message<T>>, Publisher<Message<X>>> mapper) { return new DefaultSource<>(asFlowable().compose(mapper::apply), name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> attr); } | DefaultSource implements Source<T> { @Override public <X> Source<X> compose(Function<Publisher<Message<T>>, Publisher<Message<X>>> mapper) { return new DefaultSource<>(asFlowable().compose(mapper::apply), name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> attr); @Override S... | DefaultSource implements Source<T> { @Override public <X> Source<X> compose(Function<Publisher<Message<T>>, Publisher<Message<X>>> mapper) { return new DefaultSource<>(asFlowable().compose(mapper::apply), name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> attr); @Override S... |
@Test public void testCreationWithMinimalConfiguration() throws IOException { Single<Sink<Object>> single = factory.create(vertx, null, new Config(new JsonObject() .put("bootstrap.servers", "localhost:9092") .put("key.serializer", JsonObjectSerializer.class.getName()) .put("value.serializer", JsonObjectSerializer.class... | @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } | KafkaSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } } | KafkaSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } } | KafkaSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } | KafkaSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSink<>(vertx, name, config)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } |
@Test public void testMergeWith() { Source<String> s1 = Source.from("a", "b", "c"); Source<String> s2 = Source.from("d", "e", "f"); Source<String> s3 = Source.from("g", "h"); ListSink<String> list = Sink.list(); s1.mergeWith(s2).to(list); assertThat(list.values()).containsExactly("a", "b", "c", "d", "e", "f"); Random r... | @Override public Source<T> mergeWith(Publisher<Message<T>> source) { return new DefaultSource<>(asFlowable().mergeWith(source), name, attributes); } | DefaultSource implements Source<T> { @Override public Source<T> mergeWith(Publisher<Message<T>> source) { return new DefaultSource<>(asFlowable().mergeWith(source), name, attributes); } } | DefaultSource implements Source<T> { @Override public Source<T> mergeWith(Publisher<Message<T>> source) { return new DefaultSource<>(asFlowable().mergeWith(source), name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> attr); } | DefaultSource implements Source<T> { @Override public Source<T> mergeWith(Publisher<Message<T>> source) { return new DefaultSource<>(asFlowable().mergeWith(source), name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> attr); @Override Source<T> named(String name); @Override S... | DefaultSource implements Source<T> { @Override public Source<T> mergeWith(Publisher<Message<T>> source) { return new DefaultSource<>(asFlowable().mergeWith(source), name, attributes); } DefaultSource(Publisher<Message<T>> items, String name, Map<String, Object> attr); @Override Source<T> named(String name); @Override S... |
@Test public void testGroupBy() { String text = "In 1815, M. Charles–Francois-Bienvenu Myriel was Bishop of D He was an old man of about seventy-five " + "years of age; he had occupied the see of D since 1806. Although this detail has no connection whatever with the " + "real substance of what we are about to relate, i... | @Override public <K> Publisher<GroupedDataStream<K, T>> groupBy(Function<Message<T>, K> keySupplier) { Objects.requireNonNull(keySupplier, "The function computing the key must not be `null`"); return Flowable.fromPublisher(flow) .groupBy(keySupplier::apply) .flatMapSingle(gf -> { GroupedDataStream<K, T> stream = new Gr... | DefaultSource implements Source<T> { @Override public <K> Publisher<GroupedDataStream<K, T>> groupBy(Function<Message<T>, K> keySupplier) { Objects.requireNonNull(keySupplier, "The function computing the key must not be `null`"); return Flowable.fromPublisher(flow) .groupBy(keySupplier::apply) .flatMapSingle(gf -> { Gr... | DefaultSource implements Source<T> { @Override public <K> Publisher<GroupedDataStream<K, T>> groupBy(Function<Message<T>, K> keySupplier) { Objects.requireNonNull(keySupplier, "The function computing the key must not be `null`"); return Flowable.fromPublisher(flow) .groupBy(keySupplier::apply) .flatMapSingle(gf -> { Gr... | DefaultSource implements Source<T> { @Override public <K> Publisher<GroupedDataStream<K, T>> groupBy(Function<Message<T>, K> keySupplier) { Objects.requireNonNull(keySupplier, "The function computing the key must not be `null`"); return Flowable.fromPublisher(flow) .groupBy(keySupplier::apply) .flatMapSingle(gf -> { Gr... | DefaultSource implements Source<T> { @Override public <K> Publisher<GroupedDataStream<K, T>> groupBy(Function<Message<T>, K> keySupplier) { Objects.requireNonNull(keySupplier, "The function computing the key must not be `null`"); return Flowable.fromPublisher(flow) .groupBy(keySupplier::apply) .flatMapSingle(gf -> { Gr... |
@Test public void testBranch() { Pair<Source<Integer>, Source<Integer>> branches = Source.from(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) .branch(i -> i.payload() % 3 == 0); ListSink<String> left = Sink.list(); ListSink<String> right = Sink.list(); branches.left().mapPayload(i -> Integer.toString(i)).to(left); branches.right().map... | @Override public Pair<Source<T>, Source<T>> branch(Predicate<Message<T>> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filter(condition); Source<T> right = sources.get(0).filterNot(condition); return pair(left, right); } | DefaultSource implements Source<T> { @Override public Pair<Source<T>, Source<T>> branch(Predicate<Message<T>> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filter(condition); Source<T> right = sources.get(0).filterNot(condition); return pair(left, right); } } | DefaultSource implements Source<T> { @Override public Pair<Source<T>, Source<T>> branch(Predicate<Message<T>> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filter(condition); Source<T> right = sources.get(0).filterNot(condition); return pair(left, right); } DefaultSource(Publisher... | DefaultSource implements Source<T> { @Override public Pair<Source<T>, Source<T>> branch(Predicate<Message<T>> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filter(condition); Source<T> right = sources.get(0).filterNot(condition); return pair(left, right); } DefaultSource(Publisher... | DefaultSource implements Source<T> { @Override public Pair<Source<T>, Source<T>> branch(Predicate<Message<T>> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filter(condition); Source<T> right = sources.get(0).filterNot(condition); return pair(left, right); } DefaultSource(Publisher... |
@Test public void testBranchOnPayload() { Pair<Source<Integer>, Source<Integer>> branches = Source.from(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) .branchOnPayload(i -> i % 3 == 0); ListSink<String> left = Sink.list(); ListSink<String> right = Sink.list(); branches.left().mapPayload(i -> Integer.toString(i)).to(left); branches.rig... | @Override public Pair<Source<T>, Source<T>> branchOnPayload(Predicate<T> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filterPayload(condition); Source<T> right = sources.get(0).filterNotPayload(condition); return pair(left, right); } | DefaultSource implements Source<T> { @Override public Pair<Source<T>, Source<T>> branchOnPayload(Predicate<T> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filterPayload(condition); Source<T> right = sources.get(0).filterNotPayload(condition); return pair(left, right); } } | DefaultSource implements Source<T> { @Override public Pair<Source<T>, Source<T>> branchOnPayload(Predicate<T> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filterPayload(condition); Source<T> right = sources.get(0).filterNotPayload(condition); return pair(left, right); } DefaultSo... | DefaultSource implements Source<T> { @Override public Pair<Source<T>, Source<T>> branchOnPayload(Predicate<T> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filterPayload(condition); Source<T> right = sources.get(0).filterNotPayload(condition); return pair(left, right); } DefaultSo... | DefaultSource implements Source<T> { @Override public Pair<Source<T>, Source<T>> branchOnPayload(Predicate<T> condition) { List<Source<T>> sources = broadcast(2); Source<T> left = sources.get(0).filterPayload(condition); Source<T> right = sources.get(0).filterNotPayload(condition); return pair(left, right); } DefaultSo... |
@Test(expected = IllegalArgumentException.class) public void testTupleWithNull() { Tuple.tuple("a", "b", null, "c"); } | Tuple(Object... items) { if (items == null) { this.items = Collections.emptyList(); } else { for (Object o : items) { if (o == null) { throw new IllegalArgumentException("A tuple cannot contain a `null` value"); } } this.items = Collections.unmodifiableList(Arrays.asList(items)); } } | Tuple implements Iterable<Object> { Tuple(Object... items) { if (items == null) { this.items = Collections.emptyList(); } else { for (Object o : items) { if (o == null) { throw new IllegalArgumentException("A tuple cannot contain a `null` value"); } } this.items = Collections.unmodifiableList(Arrays.asList(items)); } }... | Tuple implements Iterable<Object> { Tuple(Object... items) { if (items == null) { this.items = Collections.emptyList(); } else { for (Object o : items) { if (o == null) { throw new IllegalArgumentException("A tuple cannot contain a `null` value"); } } this.items = Collections.unmodifiableList(Arrays.asList(items)); } }... | Tuple implements Iterable<Object> { Tuple(Object... items) { if (items == null) { this.items = Collections.emptyList(); } else { for (Object o : items) { if (o == null) { throw new IllegalArgumentException("A tuple cannot contain a `null` value"); } } this.items = Collections.unmodifiableList(Arrays.asList(items)); } }... | Tuple implements Iterable<Object> { Tuple(Object... items) { if (items == null) { this.items = Collections.emptyList(); } else { for (Object o : items) { if (o == null) { throw new IllegalArgumentException("A tuple cannot contain a `null` value"); } } this.items = Collections.unmodifiableList(Arrays.asList(items)); } }... |
@Test public void testName() { assertThat(factory.name()).isEqualTo("eventbus"); } | @Override public String name() { return "eventbus"; } | EventBusSourceFactory implements SourceFactory { @Override public String name() { return "eventbus"; } } | EventBusSourceFactory implements SourceFactory { @Override public String name() { return "eventbus"; } } | EventBusSourceFactory implements SourceFactory { @Override public String name() { return "eventbus"; } @Override String name(); @Override Single<Source<T>> create(Vertx vertx, String name, Config config); } | EventBusSourceFactory implements SourceFactory { @Override public String name() { return "eventbus"; } @Override String name(); @Override Single<Source<T>> create(Vertx vertx, String name, Config config); } |
@Test(expected = IllegalArgumentException.class) public void testCreationWithoutParameter() { factory.create(vertx, null, new Config(NullNode.getInstance())); } | @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new EventBusSource<>(vertx, name, address, config)); ... | EventBusSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new ... | EventBusSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new ... | EventBusSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new ... | EventBusSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new ... |
@Test public void testCreationWithAddress() throws IOException { Single<Source<Object>> single = factory.create(vertx, null, new Config(new JsonObject().put("address", "an-address"))); Source<Object> sink = single.blockingGet(); assertThat(sink).isInstanceOf(EventBusSource.class); } | @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new EventBusSource<>(vertx, name, address, config)); ... | EventBusSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new ... | EventBusSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new ... | EventBusSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new ... | EventBusSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { String address = config.getString("address") .orElse(name); if (address == null) { throw new IllegalArgumentException("Either address or name must be set"); } return Single.just(new ... |
@Test public void testName() { assertThat(factory.name()).isEqualTo("eventbus"); } | @Override public String name() { return "eventbus"; } | EventBusSinkFactory implements SinkFactory { @Override public String name() { return "eventbus"; } } | EventBusSinkFactory implements SinkFactory { @Override public String name() { return "eventbus"; } } | EventBusSinkFactory implements SinkFactory { @Override public String name() { return "eventbus"; } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config conf); } | EventBusSinkFactory implements SinkFactory { @Override public String name() { return "eventbus"; } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config conf); } |
@Test(expected = IllegalArgumentException.class) public void testCreationWithoutParameter() { factory.create(vertx, null, new Config(NullNode.getInstance())); } | @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } | EventBusSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } } | EventBusSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } } | EventBusSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config conf); } | EventBusSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config conf); } |
@Test public void testName() { assertThat(factory.name()).isEqualTo("kafka"); } | @Override public String name() { return "kafka"; } | KafkaSourceFactory implements SourceFactory { @Override public String name() { return "kafka"; } } | KafkaSourceFactory implements SourceFactory { @Override public String name() { return "kafka"; } } | KafkaSourceFactory implements SourceFactory { @Override public String name() { return "kafka"; } @Override String name(); @Override Single<Source<T>> create(Vertx vertx, String name, Config config); } | KafkaSourceFactory implements SourceFactory { @Override public String name() { return "kafka"; } @Override String name(); @Override Single<Source<T>> create(Vertx vertx, String name, Config config); } |
@Test public void testCreationWithAddress() throws IOException { Single<Sink<Object>> single = factory.create(vertx, null, new Config(new JsonObject().put("address", "an-address"))); Sink<Object> sink = single.blockingGet(); assertThat(sink).isInstanceOf(EventBusSink.class); } | @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } | EventBusSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } } | EventBusSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } } | EventBusSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config conf); } | EventBusSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config conf) { return Single.just(new EventBusSink<>(vertx, conf)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config conf); } |
@Test public void shouldWrapIntegersIntoCamelBodies(TestContext context) throws Exception { Async async = context.async(); CamelSink<Integer> sink = new CamelSink<>( null, new Config( new JsonObject().put("endpoint", "direct:test") ) ); CamelContext camelContext = sink.camelContext(); camelContext.addRoutes(new RouteBu... | public CamelContext camelContext() { return camelContext; } | CamelSink implements Sink<T> { public CamelContext camelContext() { return camelContext; } } | CamelSink implements Sink<T> { public CamelContext camelContext() { return camelContext; } CamelSink(String name, Config config); } | CamelSink implements Sink<T> { public CamelContext camelContext() { return camelContext; } CamelSink(String name, Config config); @Override String name(); @Override Completable dispatch(Message<T> message); CamelContext camelContext(); } | CamelSink implements Sink<T> { public CamelContext camelContext() { return camelContext; } CamelSink(String name, Config config); @Override String name(); @Override Completable dispatch(Message<T> message); CamelContext camelContext(); } |
@Test public void testName() { CamelSinkFactory factory = new CamelSinkFactory(); assertThat(factory.name()).isEqualTo("camel"); } | @Override public String name() { return "camel"; } | CamelSinkFactory implements SinkFactory { @Override public String name() { return "camel"; } } | CamelSinkFactory implements SinkFactory { @Override public String name() { return "camel"; } } | CamelSinkFactory implements SinkFactory { @Override public String name() { return "camel"; } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } | CamelSinkFactory implements SinkFactory { @Override public String name() { return "camel"; } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } |
@Test(expected = IllegalArgumentException.class) public void testCreationWithoutParameter() { CamelSinkFactory factory = new CamelSinkFactory(); factory.create(vertx, null , new Config(NullNode.getInstance())); } | @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } | CamelSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } } | CamelSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } } | CamelSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } | CamelSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } |
@Test public void testCreationWithEndpoint() throws IOException { CamelSinkFactory factory = new CamelSinkFactory(); Single<Sink<Object>> single = factory.create(vertx, null , new Config(new JsonObject().put("endpoint", "my-endpoint"))); Sink<Object> sink = single.blockingGet(); assertThat(sink).isInstanceOf(CamelSink.... | @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } | CamelSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } } | CamelSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } } | CamelSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } | CamelSinkFactory implements SinkFactory { @Override public <T> Single<Sink<T>> create(Vertx vertx, String name, Config config) { return Single.just(new CamelSink<>(name, config)); } @Override String name(); @Override Single<Sink<T>> create(Vertx vertx, String name, Config config); } |
@Test public void shouldCallSubscriberOnSave(TestContext context) { Async async = context.async(); view.save(collection, key, document).subscribe(async::complete); } | @Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must not be `null`"); return Completable.fromAction... | InMemoryDocumentView implements DocumentView { @Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must... | InMemoryDocumentView implements DocumentView { @Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must... | InMemoryDocumentView implements DocumentView { @Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must... | InMemoryDocumentView implements DocumentView { @Override public synchronized Completable save(String collection, String key, Map<String, Object> document) { Objects.requireNonNull(collection, NULL_COLLECTION_MESSAGE); Objects.requireNonNull(key, NULL_KEY_MESSAGE); Objects.requireNonNull(collection, "The `document` must... |
@Test(expected = ConfigException.class) public void testCreationWithoutParameter() { factory.create(vertx, null, new Config(NullNode.getInstance())); } | @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } | KafkaSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } } | KafkaSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } } | KafkaSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } @Override String name(); @Override Single<Source<T>> create(Vertx vertx, String name, Config config); } | KafkaSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } @Override String name(); @Override Single<Source<T>> create(Vertx vertx, String name, Config config); } |
@Test public void testCreationWithMinimalConfiguration() throws IOException { Single<Source<Object>> single = factory.create(vertx, null, new Config(new JsonObject() .put("bootstrap.servers", "localhost:9092") .put("key.deserializer", JsonObjectDeserializer.class.getName()) .put("value.deserializer", JsonObjectDeserial... | @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } | KafkaSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } } | KafkaSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } } | KafkaSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } @Override String name(); @Override Single<Source<T>> create(Vertx vertx, String name, Config config); } | KafkaSourceFactory implements SourceFactory { @Override public <T> Single<Source<T>> create(Vertx vertx, String name, Config config) { return Single.just(new KafkaSource<>(vertx, name, config)); } @Override String name(); @Override Single<Source<T>> create(Vertx vertx, String name, Config config); } |
@Test public void testValidSet() throws NoSuchFieldException { Test1 test = new Test1(); Field field = Test1.class.getDeclaredField("foo"); ReflectionHelper.set(test, field, "hello"); assertThat(test.foo).isEqualTo("hello"); } | public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getClass().getName() + " ... | ReflectionHelper { public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getCla... | ReflectionHelper { public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getCla... | ReflectionHelper { public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getCla... | ReflectionHelper { public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getCla... |
@Test(expected = IllegalArgumentException.class) public void testInvalidSet() throws NoSuchFieldException { Test1 test = new Test1(); Field field = Test1.class.getDeclaredField("foo"); ReflectionHelper.set(test, field, 10); } | public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getClass().getName() + " ... | ReflectionHelper { public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getCla... | ReflectionHelper { public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getCla... | ReflectionHelper { public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getCla... | ReflectionHelper { public static void set(Object mediator, Field field, Object source) { if (!field.isAccessible()) { field.setAccessible(true); } try { field.set(mediator, source); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to set field " + field.getName() + " from " + mediator.getCla... |
@Test(expected = IllegalArgumentException.class) public void testFunctionWithNotAnnotatedParameter() throws NoSuchMethodException { InvalidBecauseOfBadParams test = new InvalidBecauseOfBadParams(); Method method = test.getClass().getMethod("function", String.class); ReflectionHelper.invokeFunction(test, method); } | public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().length() != 0) { sink ... | ReflectionHelper { public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().len... | ReflectionHelper { public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().len... | ReflectionHelper { public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().len... | ReflectionHelper { public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().len... |
@Test(expected = IllegalArgumentException.class) public void testFunctionWithoutParam() throws NoSuchMethodException { InvalidBecauseOfBadParams test = new InvalidBecauseOfBadParams(); Method method = test.getClass().getMethod("functionWithoutParam"); ReflectionHelper.invokeFunction(test, method); } | public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().length() != 0) { sink ... | ReflectionHelper { public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().len... | ReflectionHelper { public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().len... | ReflectionHelper { public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().len... | ReflectionHelper { public static void invokeFunction(Object mediator, Method method) { method = ReflectionHelper.makeAccessibleIfNot(method); List<Flowable<Object>> sources = getFlowableForParameters(method); Function function = method.getAnnotation(Function.class); Sink<Object> sink = null; if (function.outbound().len... |
@Test public void should_clone_empty_collection() { List<?> original = new ArrayList(); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_of_non_serializable_key() { Map<NonSerializableObject, String> original = new HashMap<NonSerializableObject, String>(); original.put(new NonSerializableObject("key"), "value"); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned);... | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_of_non_serializable_value() { Map<String, NonSerializableObject> original = new HashMap<String, NonSerializableObject>(); original.put("key", new NonSerializableObject("value")); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned... | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_of_serializable_key_and_value() { Map<String, SerializableObject> original = new HashMap<String, SerializableObject>(); original.put("key", new SerializableObject("value")); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_with_null_value() { Map<String, Object> original = new HashMap<String, Object>(); original.put("null", null); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_of_non_serializable_value_with_null_value() { Map<String, NonSerializableObject> original = new LinkedHashMap<String, NonSerializableObject>(); original.put("null", null); original.put("key", new NonSerializableObject("value")); Object cloned = serializer.clone(original); assertEquals... | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_of_serializable_key_and_value_with_null() { Map<String, SerializableObject> original = new LinkedHashMap<String, SerializableObject>(); original.put("null", null); original.put("key", new SerializableObject("value")); Object cloned = serializer.clone(original); assertEquals(original, ... | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void test() { doInJPA(new JPATransactionFunction<Void>() { @Override public Void apply(EntityManager entityManager) { Book book = new Book(); book.setIsbn("978-9730228236"); book.getProperties().put("title", "High-Performance Java Persistence"); book.getProperties().put("author", "Vlad Mihalcea"); book.get... | @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } PostgreSQLHStoreType(); } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } PostgreSQLHStoreType(); @Override int[] sqlTypes(); } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } PostgreSQLHStoreType(); @Override int[] sqlTypes(); static final PostgreSQLHStoreType INSTANCE; } |
@Test public void ofStringTest() { assertThat(integerRange("[1,3]").lower(), is(1)); assertThat(integerRange("[1,3]").upper(), is(3)); assertThat(integerRange("[1,3]").isUpperBoundClosed(), is(true)); assertThat(integerRange("[1,3]").isLowerBoundClosed(), is(true)); assertThat(integerRange("[,3]").lower(), is(nullValue... | @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(str.length() - 1) == ']' ? UPPER_... | Range implements Serializable { @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(s... | Range implements Serializable { @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(s... | Range implements Serializable { @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(s... | Range implements Serializable { @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(s... |
@Test public void testUnboundedRangeStringIsRejected() { try { PostgreSQLGuavaRangeType instance = PostgreSQLGuavaRangeType.INSTANCE; instance.integerRange("(,)"); fail("An unbounded range string should throw an exception!"); } catch (Exception e) { Throwable rootCause = Throwables.getRootCause(e); assertTrue(rootCause... | public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } | PostgreSQLGuavaRangeType extends ImmutableType<Range> implements DynamicParameterizedType { public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } } | PostgreSQLGuavaRangeType extends ImmutableType<Range> implements DynamicParameterizedType { public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } PostgreSQLGuavaRang... | PostgreSQLGuavaRangeType extends ImmutableType<Range> implements DynamicParameterizedType { public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } PostgreSQLGuavaRang... | PostgreSQLGuavaRangeType extends ImmutableType<Range> implements DynamicParameterizedType { public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } PostgreSQLGuavaRang... |
@Test public void cloneDeserializeStepErrorTest() { MyEntity entity = new MyEntity(); entity.setValue("some value"); entity.setPojos(Arrays.asList( createMyPojo("first value", MyType.A, "1.1", createOtherPojo("USD")), createMyPojo("second value", MyType.B, "1.2", createOtherPojo("BRL")) )); MyEntity clone = JacksonUtil... | public static <T> T clone(T value) { return ObjectMapperWrapper.INSTANCE.clone(value); } | JacksonUtil { public static <T> T clone(T value) { return ObjectMapperWrapper.INSTANCE.clone(value); } } | JacksonUtil { public static <T> T clone(T value) { return ObjectMapperWrapper.INSTANCE.clone(value); } } | JacksonUtil { public static <T> T clone(T value) { return ObjectMapperWrapper.INSTANCE.clone(value); } static T fromString(String string, Class<T> clazz); static T fromString(String string, Type type); static String toString(Object value); static JsonNode toJsonNode(String value); static T clone(T value); } | JacksonUtil { public static <T> T clone(T value) { return ObjectMapperWrapper.INSTANCE.clone(value); } static T fromString(String string, Class<T> clazz); static T fromString(String string, Type type); static String toString(Object value); static JsonNode toJsonNode(String value); static T clone(T value); } |
@Test public void testSetsAreEqual() { JsonTypeDescriptor descriptor = new JsonTypeDescriptor(); Form theFirst = createForm(1, 2, 3); Form theSecond = createForm(3, 2, 1); assertTrue(descriptor.areEqual(theFirst, theSecond)); } | @Override public boolean areEqual(Object one, Object another) { if (one == another) { return true; } if (one == null || another == null) { return false; } if (one instanceof String && another instanceof String) { return one.equals(another); } if (one instanceof Collection && another instanceof Collection) { return Obje... | JsonTypeDescriptor extends AbstractTypeDescriptor<Object> implements DynamicParameterizedType { @Override public boolean areEqual(Object one, Object another) { if (one == another) { return true; } if (one == null || another == null) { return false; } if (one instanceof String && another instanceof String) { return one.... | JsonTypeDescriptor extends AbstractTypeDescriptor<Object> implements DynamicParameterizedType { @Override public boolean areEqual(Object one, Object another) { if (one == another) { return true; } if (one == null || another == null) { return false; } if (one instanceof String && another instanceof String) { return one.... | JsonTypeDescriptor extends AbstractTypeDescriptor<Object> implements DynamicParameterizedType { @Override public boolean areEqual(Object one, Object another) { if (one == another) { return true; } if (one == null || another == null) { return false; } if (one instanceof String && another instanceof String) { return one.... | JsonTypeDescriptor extends AbstractTypeDescriptor<Object> implements DynamicParameterizedType { @Override public boolean areEqual(Object one, Object another) { if (one == another) { return true; } if (one == null || another == null) { return false; } if (one instanceof String && another instanceof String) { return one.... |
@Test public void testJPQL() { doInJPA(entityManager -> { Query jpql = entityManager .createQuery( "select " + " YEAR(p.createdOn) as year, " + " count(p) as postCount " + "from " + " Post p " + "group by " + " YEAR(p.createdOn)", Tuple.class); String sql = SQLExtractor.from(jpql); assertNotNull(sql); LOGGER.info( "The... | public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap()) .getSqlStrings... | SQLExtractor { public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap())... | SQLExtractor { public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap())... | SQLExtractor { public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap())... | SQLExtractor { public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap())... |
@Test public void testCriteriaAPI() { doInJPA(entityManager -> { CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<PostComment> criteria = builder.createQuery(PostComment.class); Root<PostComment> postComment = criteria.from(PostComment.class); Join<PostComment, Post> post = postComment.join("... | public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap()) .getSqlStrings... | SQLExtractor { public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap())... | SQLExtractor { public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap())... | SQLExtractor { public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap())... | SQLExtractor { public static String from(Query query) { AbstractProducedQuery abstractProducedQuery = query.unwrap(AbstractProducedQuery.class); String[] sqls = abstractProducedQuery .getProducer() .getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractProducedQuery.getQueryString(), false, Collections.emptyMap())... |
@Test public void should_clone_collection_of_serializable_object() { List<SerializableObject> original = new ArrayList<>(); original.add(new SerializableObject("value")); List<SerializableObject> cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_collection_of_non_serializable_object() { List<NonSerializableObject> original = new ArrayList<>(); original.add(new NonSerializableObject("value")); List<NonSerializableObject> cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void testHibernateProperties() { assertNull(Configuration.INSTANCE.getProperties().getProperty("hibernate.types.nothing")); assertEquals("def", Configuration.INSTANCE.getProperties().getProperty("hibernate.types.abc")); } | public Properties getProperties() { return properties; } | Configuration { public Properties getProperties() { return properties; } } | Configuration { public Properties getProperties() { return properties; } private Configuration(); } | Configuration { public Properties getProperties() { return properties; } private Configuration(); Properties getProperties(); ObjectMapperWrapper getObjectMapperWrapper(); Integer integerProperty(PropertyKey propertyKey); Long longProperty(PropertyKey propertyKey); Boolean booleanProperty(PropertyKey propertyKey); Cla... | Configuration { public Properties getProperties() { return properties; } private Configuration(); Properties getProperties(); ObjectMapperWrapper getObjectMapperWrapper(); Integer integerProperty(PropertyKey propertyKey); Long longProperty(PropertyKey propertyKey); Boolean booleanProperty(PropertyKey propertyKey); Cla... |
@Test public void should_clone_map_of_non_serializable_key() { Map<NonSerializableObject, String> original = new HashMap<>(); original.put(new NonSerializableObject("key"), "value"); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_of_non_serializable_value() { Map<String, NonSerializableObject> original = new HashMap<>(); original.put("key", new NonSerializableObject("value")); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_of_serializable_key_and_value() { Map<String, SerializableObject> original = new HashMap<>(); original.put("key", new SerializableObject("value")); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_with_null_value() { Map<String, Object> original = new HashMap<>(); original.put("null", null); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_of_non_serializable_value_with_null_value() { Map<String, NonSerializableObject> original = new LinkedHashMap<>(); original.put("null", null); original.put("key", new NonSerializableObject("value")); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNot... | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_map_of_serializable_key_and_value_with_null() { Map<String, SerializableObject> original = new LinkedHashMap<>(); original.put("null", null); original.put("key", new SerializableObject("value")); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(ori... | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void test() { doInJPA(entityManager -> { Book book = new Book(); book.setIsbn("978-9730228236"); book.getProperties().put("title", "High-Performance Java Persistence"); book.getProperties().put("author", "Vlad Mihalcea"); book.getProperties().put("publisher", "Amazon"); book.getProperties().put("price", "$... | @Override protected Map get(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } PostgreSQLHStoreType(); } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } PostgreSQLHStoreType(); @Override int[] sqlTypes(); } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } PostgreSQLHStoreType(); @Override int[] sqlTypes(); static final PostgreSQLHStoreType INSTANCE;... |
@Test public void ofStringTest() { assertThat(integerRange("[1,3]").lower(), is(1)); assertThat(integerRange("[1,3]").upper(), is(3)); assertThat(integerRange("[1,3]").isUpperBoundClosed(), is(true)); assertThat(integerRange("[1,3]").isLowerBoundClosed(), is(true)); assertThat(integerRange("[,3]").lower(), is(nullValue... | @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(str.length() - 1) == ']' ? UPPER_... | Range implements Serializable { @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(s... | Range implements Serializable { @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(s... | Range implements Serializable { @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(s... | Range implements Serializable { @SuppressWarnings("unchecked") public static <T extends Comparable> Range<T> ofString(String str, Function<String, T> converter, Class<T> clazz) { if(str.equals(EMPTY)) { return emptyRange(clazz); } int mask = str.charAt(0) == '[' ? LOWER_INCLUSIVE : LOWER_EXCLUSIVE; mask |= str.charAt(s... |
@Test public void localDateTimeTest() { assertNotNull(Range.localDateTimeRange("[2019-03-27 16:33:10.1,)")); assertNotNull(Range.localDateTimeRange("[2019-03-27 16:33:10.12,)")); assertNotNull(Range.localDateTimeRange("[2019-03-27 16:33:10.123,)")); assertNotNull(Range.localDateTimeRange("[2019-03-27 16:33:10.1234,)"))... | public static Range<LocalDateTime> localDateTimeRange(String range) { return ofString(range, parseLocalDateTime().compose(unquote()), LocalDateTime.class); } | Range implements Serializable { public static Range<LocalDateTime> localDateTimeRange(String range) { return ofString(range, parseLocalDateTime().compose(unquote()), LocalDateTime.class); } } | Range implements Serializable { public static Range<LocalDateTime> localDateTimeRange(String range) { return ofString(range, parseLocalDateTime().compose(unquote()), LocalDateTime.class); } private Range(T lower, T upper, int mask, Class<T> clazz); } | Range implements Serializable { public static Range<LocalDateTime> localDateTimeRange(String range) { return ofString(range, parseLocalDateTime().compose(unquote()), LocalDateTime.class); } private Range(T lower, T upper, int mask, Class<T> clazz); @SuppressWarnings("unchecked") static Range<T> closed(T lower, T upper... | Range implements Serializable { public static Range<LocalDateTime> localDateTimeRange(String range) { return ofString(range, parseLocalDateTime().compose(unquote()), LocalDateTime.class); } private Range(T lower, T upper, int mask, Class<T> clazz); @SuppressWarnings("unchecked") static Range<T> closed(T lower, T upper... |
@Test public void testHibernateTypesOverrideProperties() { assertEquals("ghi", Configuration.INSTANCE.getProperties().getProperty("hibernate.types.def")); } | public Properties getProperties() { return properties; } | Configuration { public Properties getProperties() { return properties; } } | Configuration { public Properties getProperties() { return properties; } private Configuration(); } | Configuration { public Properties getProperties() { return properties; } private Configuration(); Properties getProperties(); ObjectMapperWrapper getObjectMapperWrapper(); Integer integerProperty(PropertyKey propertyKey); Long longProperty(PropertyKey propertyKey); Boolean booleanProperty(PropertyKey propertyKey); Cla... | Configuration { public Properties getProperties() { return properties; } private Configuration(); Properties getProperties(); ObjectMapperWrapper getObjectMapperWrapper(); Integer integerProperty(PropertyKey propertyKey); Long longProperty(PropertyKey propertyKey); Boolean booleanProperty(PropertyKey propertyKey); Cla... |
@Test public void zonedDateTimeTest() { assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.1-06,)")); assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.12-06,)")); assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.123-06,)")); assertNotNull(Range.zonedDateTimeRange("[2019-03-27 16:33:10.... | public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId upperZone = range.upper().getZo... | Range implements Serializable { public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId... | Range implements Serializable { public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId... | Range implements Serializable { public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId... | Range implements Serializable { public static Range<ZonedDateTime> zonedDateTimeRange(String rangeStr) { Range<ZonedDateTime> range = ofString(rangeStr, parseZonedDateTime().compose(unquote()), ZonedDateTime.class); if (range.hasLowerBound() && range.hasUpperBound()) { ZoneId lowerZone = range.lower().getZone(); ZoneId... |
@Test public void testUnboundedRangeStringIsRejected() { try { PostgreSQLGuavaRangeType instance = PostgreSQLGuavaRangeType.INSTANCE; instance.integerRange("(,)"); fail("An unbounded range string should throw an exception!"); } catch (Exception e) { IllegalArgumentException rootCause = ExceptionUtil.rootCause(e); asser... | public static Range<Integer> integerRange(String range) { return ofString(range, Integer::parseInt, Integer.class); } | PostgreSQLGuavaRangeType extends ImmutableType<Range> implements DynamicParameterizedType { public static Range<Integer> integerRange(String range) { return ofString(range, Integer::parseInt, Integer.class); } } | PostgreSQLGuavaRangeType extends ImmutableType<Range> implements DynamicParameterizedType { public static Range<Integer> integerRange(String range) { return ofString(range, Integer::parseInt, Integer.class); } PostgreSQLGuavaRangeType(); } | PostgreSQLGuavaRangeType extends ImmutableType<Range> implements DynamicParameterizedType { public static Range<Integer> integerRange(String range) { return ofString(range, Integer::parseInt, Integer.class); } PostgreSQLGuavaRangeType(); @Override int[] sqlTypes(); @SuppressWarnings("unchecked") static Range<T> ofStrin... | PostgreSQLGuavaRangeType extends ImmutableType<Range> implements DynamicParameterizedType { public static Range<Integer> integerRange(String range) { return ofString(range, Integer::parseInt, Integer.class); } PostgreSQLGuavaRangeType(); @Override int[] sqlTypes(); @SuppressWarnings("unchecked") static Range<T> ofStrin... |
@Test public void testJPQL() { doInJPA(new JPATransactionFunction<Void>() { @Override public Void apply(EntityManager entityManager) { Query query = entityManager .createQuery( "select " + " YEAR(p.createdOn) as year, " + " count(p) as postCount " + "from " + " Post p " + "group by " + " YEAR(p.createdOn)", Tuple.class... | public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString(), false, Collec... | SQLExtractor { public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString()... | SQLExtractor { public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString()... | SQLExtractor { public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString()... | SQLExtractor { public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString()... |
@Test public void test() { doInJPA(new JPATransactionFunction<Void>() { @Override public Void apply(EntityManager entityManager) { Book book = new Book(); book.setIsbn("978-9730228236"); book.getProperties().put("title", "High-Performance Java Persistence"); book.getProperties().put("author", "Vlad Mihalcea"); book.get... | @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } PostgreSQLHStoreType(); } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } PostgreSQLHStoreType(); @Override int[] sqlTypes(); } | PostgreSQLHStoreType extends ImmutableType<Map> { @Override protected Map get(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException { return (Map) rs.getObject(names[0]); } PostgreSQLHStoreType(); @Override int[] sqlTypes(); static final PostgreSQLHStoreType INSTANCE; } |
@Test public void testCriteriaAPI() { doInJPA(new JPATransactionFunction<Void>() { @Override public Void apply(EntityManager entityManager) { CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<PostComment> criteria = builder.createQuery(PostComment.class); Root<PostComment> postComment = criter... | public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString(), false, Collec... | SQLExtractor { public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString()... | SQLExtractor { public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString()... | SQLExtractor { public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString()... | SQLExtractor { public static String from(Query query) { AbstractQueryImpl abstractQuery = query.unwrap(AbstractQueryImpl.class); SessionImplementor session = ReflectionUtils.getFieldValue(abstractQuery, "session"); String[] sqls = session.getFactory() .getQueryPlanCache() .getHQLQueryPlan(abstractQuery.getQueryString()... |
@Test public void should_clone_serializable_object() { Object original = new SerializableObject("value"); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_non_serializable_object() { Object original = new NonSerializableObject("value"); Object cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void testUnboundedRangeStringIsRejected() { try { PostgreSQLGuavaRangeType instance = PostgreSQLGuavaRangeType.INSTANCE; instance.integerRange("(,)"); fail("An unbounded range string should throw an exception!"); } catch (Exception e) { Throwable rootCause = Throwables.getRootCause(e); assertTrue(rootCause... | public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } | PostgreSQLGuavaRangeType extends ImmutableType<Range> { public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } } | PostgreSQLGuavaRangeType extends ImmutableType<Range> { public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } PostgreSQLGuavaRangeType(); } | PostgreSQLGuavaRangeType extends ImmutableType<Range> { public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } PostgreSQLGuavaRangeType(); @Override int[] sqlTypes();... | PostgreSQLGuavaRangeType extends ImmutableType<Range> { public static Range<Integer> integerRange(String range) { return ofString(range, new Function<String, Integer>() { @Override public Integer apply(String s) { return Integer.parseInt(s); } }, Integer.class); } PostgreSQLGuavaRangeType(); @Override int[] sqlTypes();... |
@Test public void should_clone_collection_of_serializable_object() { List<SerializableObject> original = new ArrayList<SerializableObject>(); original.add(new SerializableObject("value")); List<SerializableObject> cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(original, cloned); } | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void should_clone_collection_of_non_serializable_object() { List<NonSerializableObject> original = new ArrayList<NonSerializableObject>(); original.add(new NonSerializableObject("value")); List<NonSerializableObject> cloned = serializer.clone(original); assertEquals(original, cloned); assertNotSame(origina... | @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().constructParametricType(object.getClass(), firstElement.ge... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... | ObjectMapperJsonSerializer implements JsonSerializer { @Override public <T> T clone(T object) { if (object instanceof Collection) { Object firstElement = findFirstNonNullElement((Collection) object); if (firstElement != null && !(firstElement instanceof Serializable)) { JavaType type = TypeFactory.defaultInstance().con... |
@Test public void testParseAuthLineValid() throws ParseException { Authorization authorization = authorizator.parseAuthLine("topic /weather/italy/anemometer"); assertEquals(RW_ANEMOMETER, authorization); } | protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSection = true; m_currentUser = tokens[1]; m_parsingPat... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... |
@Test public void testParseAuthLineValid_read() throws ParseException { Authorization authorization = authorizator.parseAuthLine("topic read /weather/italy/anemometer"); assertEquals(R_ANEMOMETER, authorization); } | protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSection = true; m_currentUser = tokens[1]; m_parsingPat... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... |
@Test public void testParseAuthLineValid_write() throws ParseException { Authorization authorization = authorizator.parseAuthLine("topic write /weather/italy/anemometer"); assertEquals(W_ANEMOMETER, authorization); } | protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSection = true; m_currentUser = tokens[1]; m_parsingPat... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... |
@Test public void testParseAuthLineValid_readwrite() throws ParseException { Authorization authorization = authorizator.parseAuthLine("topic readwrite /weather/italy/anemometer"); assertEquals(RW_ANEMOMETER, authorization); } | protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSection = true; m_currentUser = tokens[1]; m_parsingPat... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... |
@Test public void testParseAuthLineValid_topic_with_space() throws ParseException { Authorization expected = new Authorization(new Topic("/weather/eastern italy/anemometer")); Authorization authorization = authorizator.parseAuthLine("topic readwrite /weather/eastern italy/anemometer"); assertEquals(expected, authorizat... | protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSection = true; m_currentUser = tokens[1]; m_parsingPat... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... |
@Test(expected = ParseException.class) public void testParseAuthLineValid_invalid() throws ParseException { authorizator.parseAuthLine("topic faker /weather/italy/anemometer"); } | protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSection = true; m_currentUser = tokens[1]; m_parsingPat... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... | AuthorizationsCollector implements IAuthorizator { protected Authorization parseAuthLine(String line) throws ParseException { String[] tokens = line.split("\\s+"); String keyword = tokens[0].toLowerCase(); switch (keyword) { case "topic": return createAuthorization(line, tokens); case "user": m_parsingUsersSpecificSect... |
@Test public void testParseEmpty() throws ParseException { Reader conf = new StringReader(" "); AuthorizationsCollector authorizations = ACLFileParser.parse(conf); assertTrue(authorizations.isEmpty()); } | public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback o... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... |
@Test public void testParseValidComment() throws ParseException { Reader conf = new StringReader("#simple comment"); AuthorizationsCollector authorizations = ACLFileParser.parse(conf); assertTrue(authorizations.isEmpty()); } | public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback o... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... |
@Test(expected = ParseException.class) public void testParseInvalidComment() throws ParseException { Reader conf = new StringReader(" #simple comment"); ACLFileParser.parse(conf); } | public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback o... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... |
@Test public void testParseSingleLineACL() throws ParseException { Reader conf = new StringReader("topic /weather/italy/anemometer"); AuthorizationsCollector authorizations = ACLFileParser.parse(conf); assertTrue(authorizations.canRead(new Topic("/weather/italy/anemometer"), "", "")); assertTrue(authorizations.canWrite... | public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback o... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... | ACLFileParser { public static AuthorizationsCollector parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return AuthorizationsCollector.emptyImmutableCollector(); } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %... |
@Test(expected = ParseException.class) public void parseInvalidComment() throws ParseException { Reader conf = new StringReader(" #simple comment"); m_parser.parse(conf); } | void parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return; } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath())); return; } try { FileReader rea... | ConfigurationParser { void parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return; } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath())); return; ... | ConfigurationParser { void parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return; } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath())); return; ... | ConfigurationParser { void parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return; } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath())); return; ... | ConfigurationParser { void parse(File file) throws ParseException { if (file == null) { LOG.warn("parsing NULL file, so fallback on default configuration!"); return; } if (!file.exists()) { LOG.warn( String.format( "parsing not existing file %s, so fallback on default configuration!", file.getAbsolutePath())); return; ... |
@Test public void testNotifyClientConnected() throws Exception { interceptor.notifyClientConnected(MqttMessageBuilders.connect().build()); interval(); assertEquals(40, n.get()); } | @Override public void notifyClientConnected(final MqttConnectMessage msg) { for (final InterceptHandler handler : this.handlers.get(InterceptConnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Sending MQTT CONNECT message to interceptor. CId={}, interceptorId={}", msg.payload().clientIdentifier(), handler.get... | BrokerInterceptor implements Interceptor { @Override public void notifyClientConnected(final MqttConnectMessage msg) { for (final InterceptHandler handler : this.handlers.get(InterceptConnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Sending MQTT CONNECT message to interceptor. CId={}, interceptorId={}", ms... | BrokerInterceptor implements Interceptor { @Override public void notifyClientConnected(final MqttConnectMessage msg) { for (final InterceptHandler handler : this.handlers.get(InterceptConnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Sending MQTT CONNECT message to interceptor. CId={}, interceptorId={}", ms... | BrokerInterceptor implements Interceptor { @Override public void notifyClientConnected(final MqttConnectMessage msg) { for (final InterceptHandler handler : this.handlers.get(InterceptConnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Sending MQTT CONNECT message to interceptor. CId={}, interceptorId={}", ms... | BrokerInterceptor implements Interceptor { @Override public void notifyClientConnected(final MqttConnectMessage msg) { for (final InterceptHandler handler : this.handlers.get(InterceptConnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Sending MQTT CONNECT message to interceptor. CId={}, interceptorId={}", ms... |
@Test public void testNotifyClientDisconnected() throws Exception { interceptor.notifyClientDisconnected("cli1234", "cli1234"); interval(); assertEquals(50, n.get()); } | @Override public void notifyClientDisconnected(final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptDisconnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT client disconnection to interceptor. CId={}, username={}, interceptorId={}", cli... | BrokerInterceptor implements Interceptor { @Override public void notifyClientDisconnected(final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptDisconnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT client disconnection to interceptor. ... | BrokerInterceptor implements Interceptor { @Override public void notifyClientDisconnected(final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptDisconnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT client disconnection to interceptor. ... | BrokerInterceptor implements Interceptor { @Override public void notifyClientDisconnected(final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptDisconnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT client disconnection to interceptor. ... | BrokerInterceptor implements Interceptor { @Override public void notifyClientDisconnected(final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptDisconnectMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT client disconnection to interceptor. ... |
@Test public void testNotifyTopicPublished() throws Exception { MqttPublishMessage msg = MqttMessageBuilders.publish().qos(MqttQoS.AT_MOST_ONCE).payload(Unpooled.copiedBuffer("Hello".getBytes())).build(); MoquetteMessage moquetteMessage = new MoquetteMessage(msg.fixedHeader(), msg.variableHeader(), msg.content()); inte... | @Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifyin... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicPublished(final MoquetteMessage msg, final String clientID, final String username) { int messageId = msg.getMessageId(); String topic = msg.getTopic(); for (final InterceptHandler handler : this.handlers.get(InterceptPublishMessage.class)) { if... |
@Test public void testNotifyTopicSubscribed() throws Exception { interceptor.notifyTopicSubscribed(new Subscription("cli1", new Topic("o2"), MqttQoS.AT_MOST_ONCE), "cli1234"); interval(); assertEquals(70, n.get()); } | @Override public void notifyTopicSubscribed(final Subscription sub, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptSubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT SUBSCRIBE message to interceptor. CId={}, topicFilter={}, interceptorId={}", sub.ge... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicSubscribed(final Subscription sub, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptSubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT SUBSCRIBE message to interceptor. CId={}... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicSubscribed(final Subscription sub, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptSubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT SUBSCRIBE message to interceptor. CId={}... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicSubscribed(final Subscription sub, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptSubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT SUBSCRIBE message to interceptor. CId={}... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicSubscribed(final Subscription sub, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptSubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT SUBSCRIBE message to interceptor. CId={}... |
@Test public void testNotifyTopicUnsubscribed() throws Exception { interceptor.notifyTopicUnsubscribed("o2", "cli1234", "cli1234"); interval(); assertEquals(80, n.get()); } | @Override public void notifyTopicUnsubscribed(final String topic, final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptUnsubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT UNSUBSCRIBE message to interceptor. CId={}, topic={}, interc... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicUnsubscribed(final String topic, final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptUnsubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT UNSUBSCRIBE messa... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicUnsubscribed(final String topic, final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptUnsubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT UNSUBSCRIBE messa... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicUnsubscribed(final String topic, final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptUnsubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT UNSUBSCRIBE messa... | BrokerInterceptor implements Interceptor { @Override public void notifyTopicUnsubscribed(final String topic, final String clientID, final String username) { for (final InterceptHandler handler : this.handlers.get(InterceptUnsubscribeMessage.class)) { if(LOG.isDebugEnabled()){ LOG.debug("Notifying MQTT UNSUBSCRIBE messa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.