@Test public void withScenarioFailOptional() { assertThat(withScenario.failOptional(null, "foo")) .hasValueSatisfying(ae -> assertThat(ae).hasMessage("[ErrorFormatterTest] expectation failed (foo)")); }
@Test public void noScenarioFailOptional() { assertThat(noScenario.failOptional(null, "foo")) .hasValueSatisfying(ae -> assertThat(ae).hasMessage("expectation failed (foo)")); }
@Test public void testPull88WeirdValueArgumentFactory() { handle.registerArgument(new WeirdValueArgumentFactory()); assertThat(ctx.findArgumentFor(Weird.class, new Weird())) .hasValueSatisfying(a -> assertThat(a).isInstanceOf(WeirdArgument.class)); assertThat(ctx.findArgumentFor(Object.class, new Weird())) .hasValueSatisfying(a -> assertThat(a).isInstanceOf(WeirdArgument.class)); assertThat(ctx.findArgumentFor(Weird.class, null)) .hasValueSatisfying(a -> assertThat(a).isInstanceOf(NullArgument.class)); assertThat(ctx.findArgumentFor(Object.class, null)) .hasValueSatisfying(a -> assertThat(a).isInstanceOf(NullArgument.class)); }
@Test public void testPull88WeirdClassArgumentFactory() { handle.registerArgument(new WeirdClassArgumentFactory()); assertThat(ctx.findArgumentFor(Weird.class, new Weird())) .hasValueSatisfying(a -> assertThat(a).isInstanceOf(WeirdArgument.class)); assertThat(ctx.findArgumentFor(Weird.class, null)) .hasValueSatisfying(a -> assertThat(a).isInstanceOf(WeirdArgument.class)); assertThat(ctx.findArgumentFor(Object.class, new Weird())) .isEmpty(); assertThat(ctx.findArgumentFor(Object.class, null)) .hasValueSatisfying(a -> assertThat(a).isInstanceOf(NullArgument.class)); }
@Test public void testBeanMapperFactoryDefaultMethod() { BeanMappingDao bdb = dbRule.getSharedHandle().attach(BeanMappingDao.class); bdb.createBeanTable(); Bean lima = new Bean(); lima.setColor("green"); lima.setName("lima"); bdb.insertBean(lima); assertThat(bdb.findByNameDefaultMethod("lima")) .hasValueSatisfying(bean -> { assertThat(bean).extracting(Bean::getName, Bean::getColor) .contains(lima.getName(), lima.getColor()); }); }
@Test public void canStoreAndRetrieveValues() { CheckAndSetResult<ValueAndBound<String>> casResult = coordinationStore.transformAgreedValue(unused -> VALUE_1); assertThat(casResult.successful()).isTrue(); assertThat(Iterables.getOnlyElement(casResult.existingValues()).value()).contains(VALUE_1); assertThat(coordinationStore.getAgreedValue()).hasValueSatisfying( valueAndBound -> { assertThat(valueAndBound.value()).contains(VALUE_1); assertThat(valueAndBound.bound()).isGreaterThanOrEqualTo(0); }); }
public AssertZipContent hasContentSatisfying(String entry, Consumer<String> requirement) { assertThat(zipContent(entry)).hasValueSatisfying(requirement); return this; }
public AssertZipContent hasJsonContent(String entry) { assertThat(zipContent(entry)).hasValueSatisfying(JsonFluentAssert::assertThatJson); return this; }
@Test public void createNodeAlreadyBound() throws Exception { assertThatThrownBy(() -> submitAndGet("CREATE (n:Foo)\n" + "CREATE (n:Bar)-[:OWNS]->(:Dog)")) .satisfies(t -> { Optional<String> getStackTrace = getInitialCause(t); assertThat(getStackTrace).hasValueSatisfying(stackTrace -> assertThat(stackTrace).contains("SyntaxException") ); }); }
@Test public void createRelationshipInvalidSyntax() throws Exception { assertThatThrownBy(() -> submitAndGet("CREATE ({id: 2})-[r:KNOWS]-({id: 1}) RETURN r")) .satisfies(t -> { Optional<String> getStackTrace = getInitialCause(t); assertThat(getStackTrace).hasValueSatisfying(stackTrace -> assertThat(stackTrace).contains("SyntaxException") ); }); }
@Test public void toOutputPropertiesShouldReturnHeadersMessagePropertyWhenIndividualHeadersRequested() { MessageProperties actual = new MessageProperties( Optional.of(ImmutableSet.of("headers.X-Spam-Score"))).toOutputProperties(); assertThat(actual.getOptionalMessageProperties()).hasValueSatisfying( value -> assertThat(value).contains(MessageProperty.headers) ); assertThat(actual.getOptionalHeadersProperties()).hasValueSatisfying( value -> assertThat(value).contains(HeaderProperty.fromFieldName("x-spam-score")) ); } }
@Test public void toOutputPropertiesShouldReturnIsUnread() { MessageProperties actual = new MessageProperties(Optional.of(ImmutableSet.of("isUnread"))).toOutputProperties(); assertThat(actual.getOptionalMessageProperties()) .hasValueSatisfying(value -> assertThat(value).contains(MessageProperty.isUnread)); }
@Test public void shouldProvideValidDropAndCreateStatementsForConstraints() { Optional<AutoIndex> optionalAutoIndex = AutoIndex.parse("CONSTRAINT ON ( x:X ) ASSERT x.objId IS UNIQUE"); assertThat(optionalAutoIndex).isPresent(); assertThat(optionalAutoIndex).hasValueSatisfying(index -> { assertThat(index.getCreateStatement().getStatement()) .isEqualTo("CREATE CONSTRAINT ON (`x`:`X`) ASSERT `x`.`objId` IS UNIQUE"); assertThat(index.getDropStatement().getStatement()) .isEqualTo("DROP CONSTRAINT ON (`x`:`X`) ASSERT `x`.`objId` IS UNIQUE"); assertThat(index.getDescription()).isEqualTo("CONSTRAINT ON (`x`:`X`) ASSERT `x`.`objId` IS UNIQUE"); }); }
@Test public void shouldProvideValidDropAndCreateStatementsForIndexes() { Optional<AutoIndex> optionalAutoIndex = AutoIndex.parse("INDEX ON :X(deprecated)"); assertThat(optionalAutoIndex).isPresent(); assertThat(optionalAutoIndex).hasValueSatisfying(index -> { assertThat(index.getCreateStatement().getStatement()).isEqualTo("CREATE INDEX ON :`X`(`deprecated`)"); assertThat(index.getDropStatement().getStatement()).isEqualTo("DROP INDEX ON :`X`(`deprecated`)"); assertThat(index.getDescription()).isEqualTo("INDEX ON :`X`(`deprecated`)"); }); } }
@Test public void toOutputPropertiesShouldReturnTextBodyWhenBodyRequested() { MessageProperties actual = new MessageProperties(Optional.of(ImmutableSet.of("body"))).toOutputProperties(); assertThat(actual.getOptionalMessageProperties()) .hasValueSatisfying(value -> assertThat(value).contains(MessageProperty.textBody).doesNotContain(MessageProperty.body)); }
@Test public void toOutputPropertiesShouldReturnAllHeadersWhenHeadersAndIndividualHeadersRequested() { MessageProperties actual = new MessageProperties( Optional.of(ImmutableSet.of("headers.X-Spam-Score", "headers"))).toOutputProperties(); assertThat(actual.getOptionalMessageProperties()).hasValueSatisfying( value -> assertThat(value).contains(MessageProperty.headers) ); assertThat(actual.getOptionalHeadersProperties()).isEmpty(); }
@Test public void shouldMakeNonUniqueOperationIdsUnique() { final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo")) .post(new Operation().operationId("foo")).put(new Operation().operationId("bar"))); final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(), createSettingsFrom(swagger)); final List<ConnectorAction> actions = generated.getActions(); assertThat(actions).hasSize(3); assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo")); assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1")); assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar")); }
@Test public void shouldMakeNonUniqueOperationIdsUnique() { final Swagger swagger = new Swagger().path("/path", new Path().get(new Operation().operationId("foo")) .post(new Operation().operationId("foo")).put(new Operation().operationId("bar"))); final Connector generated = generator.configureConnector(SWAGGER_TEMPLATE, new Connector.Builder().id("connector1").build(), createSettingsFrom(swagger)); final List<ConnectorAction> actions = generated.getActions(); assertThat(actions).hasSize(3); assertThat(actions.get(0).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo")); assertThat(actions.get(1).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("foo1")); assertThat(actions.get(2).getId()).hasValueSatisfying(id -> assertThat(id).endsWith("bar")); }
@Test public void shouldGiveLogsInStream() { containerId = dockerClient.createContainerCmd(WANTED_IMAGE).withEnv(singletonList("WAITING_TIME=1ms")) .exec() .getId(); dockerClient.startContainerCmd(containerId).exec(); Stream<String> logs = defaultDockerClient.logs(containerId); Optional<String> firstLine = logs.findFirst(); assertThat(firstLine).isPresent() .hasValueSatisfying("started"::equals); } }
@Test public void testBeanMapperFactoryDefaultMethod() { BeanMappingDao bdb = dbRule.getSharedHandle().attach(BeanMappingDao.class); bdb.createBeanTable(); Bean lima = new Bean(); lima.setColor("green"); lima.setName("lima"); bdb.insertBean(lima); assertThat(bdb.findByNameDefaultMethod("lima")) .hasValueSatisfying(bean -> { assertThat(bean).extracting(Bean::getName, Bean::getColor) .contains(lima.getName(), lima.getColor()); }); }