本文整理了Java中reactor.util.context.Context.stream()
方法的一些代码示例,展示了Context.stream()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.stream()
方法的具体详情如下:
包路径:reactor.util.context.Context
类名称:Context
方法名:stream
[英]Stream key/value pairs from this Context
[中]来自此上下文的流键/值对
代码示例来源:origin: reactor/reactor-core
@Override
public StepVerifier.ContextExpectations<T> containsAllOf(Context other) {
this.contextExpectations = this.contextExpectations.andThen(c -> {
boolean all = other.stream().allMatch(e -> e.getValue().equals(c.getOrDefault(e.getKey(), null)));
if (!all) {
throw errorFormatter.assertionError(String.format("Expected Context %s to contain all of %s", c, other));
}
});
return this;
}
代码示例来源:origin: reactor/reactor-core
@Override
public Context putAll(Context other) {
if (other.isEmpty()) return this;
if (other instanceof ContextN) return new ContextN(this, ((ContextN) other));
Map<?, ?> mapOther = other.stream()
.collect(Collectors.toMap(Entry::getKey, Entry::getValue));
return new ContextN(this, mapOther);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void putAnyKeyContext1() throws Exception {
Context put = c.put(1, "Abis");
assertThat(put)
.isInstanceOf(Context1.class);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("Abis");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void putDifferentKeyContextN() throws Exception {
Context put = c.put(6, "Abis");
assertThat(put)
.isInstanceOf(ContextN.class);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3, 4, 5, 6);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("A", "B", "C", "D", "E", "Abis");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void putDifferentKeyContext3() throws Exception {
Context put = c.put(3, "Abis");
assertThat(put)
.isInstanceOf(Context3.class);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("A", "B", "Abis");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey1NewContext() throws Exception {
Context put = c.put(1, "foo");
assertThat(put)
.isInstanceOf(Context1.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("foo");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey1NewContext() throws Exception {
Context put = c.put(1, "foo");
assertThat(put)
.isInstanceOf(Context4.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3, 4);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("foo", "B", "C", "D");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey1NewContext() throws Exception {
Context put = c.put(1, "foo");
assertThat(put)
.isInstanceOf(ContextN.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3, 4, 5, 6);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("foo", "B", "C", "D", "E", "F");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey5NewContext() {
Context put = c.put(5, "foo");
assertThat(put)
.isInstanceOf(ContextN.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3, 4, 5, 6);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("A", "B", "C", "D", "foo", "F");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey1NewContext() throws Exception {
Context put = c.put(1, "foo");
assertThat(put)
.isInstanceOf(Context5.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3, 4, 5);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("foo", "B", "C", "D", "E");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey3NewContext() {
Context put = c.put(3, "foo");
assertThat(put)
.isInstanceOf(Context5.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3, 4, 5);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("A", "B", "foo", "D", "E");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey3NewContext() {
Context put = c.put(3, "foo");
assertThat(put)
.isInstanceOf(Context4.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3, 4);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("A", "B", "foo", "D");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey4NewContext() {
Context put = c.put(4, "foo");
assertThat(put)
.isInstanceOf(Context4.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3, 4);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("A", "B", "C", "foo");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey3NewContext() {
Context put = c.put(3, "foo");
assertThat(put)
.isInstanceOf(Context3.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("A", "B", "foo");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey2NewContext() {
Context put = c.put(2, "foo");
assertThat(put)
.isInstanceOf(Context2.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("A", "foo");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void replaceKey4NewContext() {
Context put = c.put(4, "foo");
assertThat(put)
.isInstanceOf(ContextN.class)
.isNotSameAs(c);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactly(1, 2, 3, 4, 5, 6);
assertThat(put.stream().map(Map.Entry::getValue))
.containsExactly("A", "B", "C", "foo", "E", "F");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void of2() throws Exception {
Context c = Context.of(1, 100, 2, 200);
assertThat(c).isInstanceOf(Context2.class);
assertThat(c.isEmpty()).as("isEmpty").isFalse();
assertThat(c.stream()).hasSize(2);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void of5() throws Exception {
Context c = Context.of(1, 100, 2, 200, 3, 300, 4, 400, 5, 500);
assertThat(c).isInstanceOf(Context5.class);
assertThat(c.isEmpty()).as("isEmpty").isFalse();
assertThat(c.stream()).hasSize(5);
}
代码示例来源:origin: reactor/reactor-core
@Test
public void putAllOf() {
Context m = Context.of("A", 1, "B", 2, "C", 3);
Context put = c.putAll(m);
assertThat(put).isInstanceOf(ContextN.class);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactlyInAnyOrder(1, 2, 3, 4, "A", "B", "C");
}
代码示例来源:origin: reactor/reactor-core
@Test
public void putAllOfContext3() {
Context m = Context.of("A", 1, "B", 2, "C", 3);
Context put = c.putAll(m);
assertThat(put).isInstanceOf(ContextN.class);
assertThat(put.stream().map(Map.Entry::getKey))
.containsExactlyInAnyOrder(1, 2, 3, 4, 5, 6, "A", "B", "C");
}
内容来源于网络,如有侵权,请联系作者删除!