@Test public void shouldPassPositiveDuration() { // Given final List<Long> positiveIntervals = List.of(10L, 99L, 981L); final List<Duration> positiveDurations = positiveIntervals.map(Duration::ofMillis); // When positiveDurations.forEach(IntervalFunction::of); positiveIntervals.forEach(IntervalFunction::of); positiveDurations.forEach(IntervalFunction::ofRandomized); positiveIntervals.forEach(IntervalFunction::ofRandomized); positiveDurations.forEach(IntervalFunction::ofExponentialBackoff); positiveIntervals.forEach(IntervalFunction::ofExponentialBackoff); positiveDurations.forEach(IntervalFunction::ofExponentialRandomBackoff); positiveIntervals.forEach(IntervalFunction::ofExponentialRandomBackoff); // Then should pass }
@Test public void shouldPassPositiveRandomizationFactor() { // Given final Duration duration = Duration.ofMillis(100); final float multiplier = 1.5f; final List<Float> correctFactors = List.of(0.0f, 0.25f, 0.5f, 0.75f, 0.1f); // When correctFactors.forEach(v -> IntervalFunction.ofRandomized(duration, v)); correctFactors.forEach(v -> IntervalFunction.ofExponentialRandomBackoff(duration, multiplier, v)); }
final AtomicBoolean completed = new AtomicBoolean(false); final AtomicInteger count = new AtomicInteger(list.length()); list.forEach(future -> future.onComplete(result -> { synchronized (count) {
@Override public final void apply() { sources.forEach(jp -> jp.saveIn(workingDirectory)); } }
@Override public final void apply(final ClassPath classPath, final ClassNames classNames, final Path workingDirectory) { System.out.println(); System.out.println("java.home: " + System.getProperty("java.home")); System.out.println("java.class.path:"); classPath.paths().forEach(p -> System.out.println(" " + p)); System.out.println(); } }
private static void row( final Document doc, final Element releases, final String date_text, final List<Node> td_text_nodes) { final Element tr = doc.createElementNS(XHTML_NS, "tr"); final Element td_date = doc.createElementNS(XHTML_NS, "td"); td_date.setTextContent(date_text); final Element td_text = doc.createElementNS(XHTML_NS, "td"); td_text_nodes.forEach(td_text::appendChild); tr.appendChild(td_date); tr.appendChild(td_text); releases.appendChild(tr); }
private void writeRelease( final Document doc, final Element releases, final CVersionType version, final CRelease release) { final Element e_release = doc.createElementNS(this.schema_uri, "c:release"); e_release.setAttribute( "date", this.date_formatter.format(release.date())); e_release.setAttribute( "version", version.toVersionString()); e_release.setAttribute( "ticket-system", release.ticketSystemID()); final Element changes = doc.createElementNS(this.schema_uri, "c:changes"); release.changes().forEach( change -> this.writeChange(doc, changes, change)); e_release.appendChild(changes); releases.appendChild(e_release); }
doc.createElementNS(this.schema_uri, "c:tickets"); change_tickets.forEach(ticket -> { final Element e_ticket = doc.createElementNS(this.schema_uri, "c:ticket");
this.writer.newLine(); release.changes().reverse().forEach(change -> { try { if (this.config.showDates()) {
public void validateNamespaces() { getLinks().forEach(link -> namespaceManager.validateNamespaces(Links.getRel(link))); resources.forEach( (key, rel) -> { namespaceManager.validateNamespaces(key); rel.validateNamespaces(); }); }
final AtomicBoolean completed = new AtomicBoolean(false); final AtomicInteger count = new AtomicInteger(list.length()); list.forEach(future -> future.onComplete(result -> { synchronized (count) {
/** * Add a link to this resource. * * @param links The target link */ public ResourceRepresentation<V> withLinks(List<Link> links) { links.forEach( link -> { String rel = Links.getRel(link); Support.checkRelType(rel); validateSingletonRel(rel); }); final TreeMap<String, Rel> updatedRels = links .map(Links::getRel) .foldLeft( rels, (accum, rel) -> !accum.containsKey(rel) ? accum.put(rel, Rels.natural(rel)) : accum); final List<Link> updatedLinks = this.links.appendAll(links); return new ResourceRepresentation<>( content, updatedLinks, updatedRels, namespaceManager, value, resources); }
@Test public void test2() throws IOException { ComplexInnerClass innerSrc = new ComplexInnerClass(); innerSrc.setScalar(10); innerSrc.setValues(List.of("Data1", "Data2", "Data3")); ComplexBeanObject src = new ComplexBeanObject(); src.setScalar("Data Scalar"); src.setValues(List.of( new ComplexInnerClass(10, List.of("Data1", "Data2", "Data3")), new ComplexInnerClass(12, List.of("Data3", "Data4", "Data5")) )); String json = mapper().writeValueAsString(src); ComplexBeanObject restored = mapper().readValue(json, ComplexBeanObject.class); restored.getValues().forEach(innerClass -> { Assert.assertTrue("Instance of ComplexInnerClass", innerClass instanceof ComplexInnerClass); }); Assert.assertEquals(restored, src); }