Java Code Examples for org.assertj.core.util.Lists#list()
The following examples show how to use
org.assertj.core.util.Lists#list() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CsvImportTest.java From kid-bank with Apache License 2.0 | 6 votes |
@Test public void multipleDepositRowsShouldResultInMultipleDepositTransactions() throws Exception { List<String> csvList = Lists.list( "05/03/2018,Cash Deposit, $6.75 ,Bottle return", "05/24/2018,Deposit, $7.75 ,Bottle return"); List<Transaction> transactions = new CsvImporter().importFrom(csvList); assertThat(transactions) .usingElementComparatorIgnoringFields("id") .containsExactly( CsvImporter.createDeposit(LocalDateTime.of(2018, 5, 3, 0, 0), 675, "Bottle return"), CsvImporter.createDeposit(LocalDateTime.of(2018, 5, 24, 0, 0), 775, "Bottle return")); }
Example 2
Source File: AcknowledgementLabelsTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Parameterized.Parameters(name = "{0}") public static List<RegexValidationParameter> validationParameters() { return Lists.list( RegexValidationParameter.invalid("A"), RegexValidationParameter.invalid("AB"), RegexValidationParameter.valid("ABC"), RegexValidationParameter.valid(IntStream.range(0, 64) .mapToObj(i -> "a") .collect(Collectors.joining())), RegexValidationParameter.invalid(IntStream.range(0, 65) .mapToObj(i -> "b") .collect(Collectors.joining())), RegexValidationParameter.invalid("ab?"), RegexValidationParameter.valid("---"), RegexValidationParameter.valid("___"), RegexValidationParameter.valid("FOO-BAR"), RegexValidationParameter.valid("0123456789") ); }
Example 3
Source File: NamespacedEntityIdWithTypeTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Parameterized.Parameters(name = "{0}") public static List<CompatibilityCheckParameter> testParameters() { return Lists.list( CompatibilityCheckParameter.compatible(createEntityId("", "baz"), createEntityId("", "baz")), CompatibilityCheckParameter.compatible(createEntityId("foo", "bar"), createEntityId("foo", "bar")), CompatibilityCheckParameter.compatible(createEntityId("", "baz"), createEntityId("foo", "baz")), CompatibilityCheckParameter.compatible(createEntityId("foo", "baz"), createEntityId("", "baz")), CompatibilityCheckParameter.incompatible(createEntityId("foo", "baz"), null), CompatibilityCheckParameter.incompatible(createEntityId("", "baz"), createEntityId("", "bar")), CompatibilityCheckParameter.incompatible(createEntityId("foo", "baz"), createEntityId("", "bar")), CompatibilityCheckParameter.incompatible(createEntityId("", "baz"), createEntityId("baz", "bar")), CompatibilityCheckParameter.incompatible(createEntityId("", "foo"), createEntityId("foo", "bar")), CompatibilityCheckParameter.incompatible(createEntityId("foo", "baz"), createEntityId("", "bar")), CompatibilityCheckParameter.incompatible(createEntityId("foo", "bar"), createEntityId("foo", "baz")), CompatibilityCheckParameter.incompatible(createEntityId("foo", "baz"), createEntityId("bar", "baz")), CompatibilityCheckParameter.incompatible(createEntityId("foo", "bar"), createEntityId("bar", "foo")), CompatibilityCheckParameter.incompatible(createEntityId(ENTITY_TYPE_PLUMBUS, "foo", "bar"), createEntityId(ENTITY_TYPE_GRUMBO, "foo", "bar")) ); }
Example 4
Source File: ImmutableAcknowledgementsTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Test public void getAcknowledgementReturnsExpected() { final Acknowledgement timeoutAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, KNOWN_ENTITY_ID, HttpStatusCode.REQUEST_TIMEOUT, KNOWN_DITTO_HEADERS, null); final AcknowledgementLabel customAckLabel = AcknowledgementLabel.of("foo"); final Acknowledgement customAcknowledgement = ImmutableAcknowledgement.of(customAckLabel, KNOWN_ENTITY_ID, HttpStatusCode.OK, KNOWN_DITTO_HEADERS, null); final List<Acknowledgement> acknowledgements = Lists.list(KNOWN_ACK_1, timeoutAcknowledgement, customAcknowledgement); final ImmutableAcknowledgements underTest = ImmutableAcknowledgements.of(acknowledgements, KNOWN_DITTO_HEADERS); assertThat(underTest.getAcknowledgement(DittoAcknowledgementLabel.TWIN_PERSISTED)) .contains(timeoutAcknowledgement); assertThat(underTest.getAcknowledgement(customAckLabel)).contains(customAcknowledgement); }
Example 5
Source File: ReadJsonArrayHeadersFilterTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Test public void filterJsonArrayStringRepresentation() { final List<AcknowledgementRequest> acknowledgementRequests = Lists.list( AcknowledgementRequest.of(AcknowledgementLabel.of("foo")), AcknowledgementRequest.of(AcknowledgementLabel.of("bar"))); final JsonArray acknowledgementRequestsJsonArray = acknowledgementRequests.stream() .map(AcknowledgementRequest::toString) .map(JsonValue::of) .collect(JsonCollectors.valuesToArray()); final String jsonArrayStringRepresentation = acknowledgementRequestsJsonArray.toString(); final ReadJsonArrayHeadersFilter underTest = ReadJsonArrayHeadersFilter.getInstance(headerDefinitions); final String filteredValue = underTest.filterValue(HEADER_DEFINITION.getKey(), jsonArrayStringRepresentation); assertThat(filteredValue).isEqualTo(jsonArrayStringRepresentation); }
Example 6
Source File: DittoAckRequestsFilterTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Test public void filterValueWithDittoInternalRequests() { final DittoHeaderDefinition headerDefinition = DittoHeaderDefinition.REQUESTED_ACKS; final List<AcknowledgementRequest> allAcknowledgementRequests = Lists.list( AcknowledgementRequest.of(AcknowledgementLabel.of("foo")), AcknowledgementRequest.of(DittoAcknowledgementLabel.TWIN_PERSISTED), AcknowledgementRequest.of(AcknowledgementLabel.of("bar"))); final JsonArray allAcknowledgementRequestsJsonArray = allAcknowledgementRequests.stream() .map(AcknowledgementRequest::toString) .map(JsonValue::of) .collect(JsonCollectors.valuesToArray()); final String value = allAcknowledgementRequestsJsonArray.toString(); final JsonArray externalAcknowledgementRequests = allAcknowledgementRequestsJsonArray.toBuilder() .remove(1) .build(); final String expected = externalAcknowledgementRequests.toString(); final DittoAckRequestsFilter underTest = DittoAckRequestsFilter.getInstance(); assertThat(underTest.apply(headerDefinition.getKey(), value)).isEqualTo(expected); }
Example 7
Source File: DittoAckRequestsFilterTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Test public void filterValueWithoutDittoInternalRequests() { final DittoHeaderDefinition headerDefinition = DittoHeaderDefinition.REQUESTED_ACKS; final List<AcknowledgementRequest> acknowledgementRequests = Lists.list( AcknowledgementRequest.of(AcknowledgementLabel.of("foo")), AcknowledgementRequest.of(AcknowledgementLabel.of("bar"))); final JsonArray acknowledgementRequestsJsonArray = acknowledgementRequests.stream() .map(AcknowledgementRequest::toString) .map(JsonValue::of) .collect(JsonCollectors.valuesToArray()); final String value = acknowledgementRequestsJsonArray.toString(); final DittoAckRequestsFilter underTest = DittoAckRequestsFilter.getInstance(); assertThat(underTest.apply(headerDefinition.getKey(), value)).isEqualTo(value); }
Example 8
Source File: HeaderEntryFiltersTest.java From ditto with Eclipse Public License 2.0 | 6 votes |
@Test public void toExternalHeadersFilterDiscardsDittoInternalAckRequests() { final DittoHeaderDefinition headerDefinition = DittoHeaderDefinition.REQUESTED_ACKS; final Map<String, HeaderDefinition> headerDefinitions = Maps.newHashMap(headerDefinition.getKey(), headerDefinition); final List<AcknowledgementRequest> allAcknowledgementRequests = Lists.list( AcknowledgementRequest.of(AcknowledgementLabel.of("foo")), AcknowledgementRequest.of(DittoAcknowledgementLabel.TWIN_PERSISTED), AcknowledgementRequest.of(AcknowledgementLabel.of("bar"))); final JsonArray allAcknowledgementRequestsJsonArray = allAcknowledgementRequests.stream() .map(AcknowledgementRequest::toString) .map(JsonValue::of) .collect(JsonCollectors.valuesToArray()); final String value = allAcknowledgementRequestsJsonArray.toString(); final JsonArray externalAcknowledgementRequests = allAcknowledgementRequestsJsonArray.toBuilder() .remove(1) .build(); final String expected = externalAcknowledgementRequests.toString(); final HeaderEntryFilter underTest = HeaderEntryFilters.toExternalHeadersFilter(headerDefinitions); assertThat(underTest.apply(headerDefinition.getKey(), value)).isEqualTo(expected); }
Example 9
Source File: HeaderTranslatorTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void translateDittoHeadersWithAckRequestToExternal() { final String correlationId = "correlation-id"; final List<AcknowledgementRequest> allAcknowledgementRequests = Lists.list( AcknowledgementRequest.of(AcknowledgementLabel.of("foo")), AcknowledgementRequest.of(DittoAcknowledgementLabel.TWIN_PERSISTED), AcknowledgementRequest.of(AcknowledgementLabel.of("bar"))); final DittoHeaders dittoHeaders = DittoHeaders.newBuilder() .correlationId(correlationId) .acknowledgementRequests(allAcknowledgementRequests) .build(); final JsonArray allAcknowledgementRequestsJsonArray = allAcknowledgementRequests.stream() .map(AcknowledgementRequest::toString) .map(JsonValue::of) .collect(JsonCollectors.valuesToArray()); final JsonArray externalAcknowledgementRequests = allAcknowledgementRequestsJsonArray.toBuilder() .remove(1) .build(); final Map<String, String> expected = new HashMap<>(); expected.put(DittoHeaderDefinition.CORRELATION_ID.getKey(), correlationId); expected.put(DittoHeaderDefinition.REQUESTED_ACKS.getKey(), externalAcknowledgementRequests.toString()); expected.put(DittoHeaderDefinition.RESPONSE_REQUIRED.getKey(), Boolean.TRUE.toString()); final HeaderTranslator underTest = HeaderTranslator.of(DittoHeaderDefinition.values()); assertThat(underTest.toExternalHeaders(dittoHeaders)).isEqualTo(expected); }
Example 10
Source File: JmxRegistrarTest.java From smallrye-metrics with Apache License 2.0 | 5 votes |
@Test public void shouldReplaceMultipleWildcards() { assertThat(getMetadataCalled("test_key")).hasSize(1); final ExtendedMetadataAndTags extendedMetadata = getSingleMatch("test_key"); assertThat(extendedMetadata.getMetadata().getName()).isEqualTo("test_key"); assertThat(extendedMetadata.getMetadata().getDescription()).isEqualTo("Description %s1-%s2"); assertThat(extendedMetadata.getMetadata().getDisplayName()).isEqualTo("Display Name %s1-%s2"); assertThat(extendedMetadata.getMetadata().getMbean()).isEqualTo("java.nio:name=%s2,type=%s1/ObjectName"); assertThat(extendedMetadata.getTags()).contains( new Tag("type", "%s1"), new Tag("name", "%s2")); assertThat(extendedMetadata.getMetadata().getType()).isEqualTo("counter"); assertThat(extendedMetadata.getMetadata().getUnit()).isEqualTo("none"); final List<ExtendedMetadataAndTags> metadataList = Lists.list(extendedMetadata); JmxWorker.instance().expandMultiValueEntries(metadataList); final ExtendedMetadataAndTags extendedMetadata1 = metadataList.get(0); assertThat(extendedMetadata1.getMetadata().getDescription()).isEqualTo("Description BufferPool-mapped"); assertThat(extendedMetadata1.getMetadata().getDisplayName()).isEqualTo("Display Name BufferPool-mapped"); assertThat(extendedMetadata1.getMetadata().getMbean()).isEqualTo("java.nio:name=mapped,type=BufferPool/ObjectName"); assertThat(extendedMetadata1.getTags()).contains( new Tag("type", "BufferPool"), new Tag("name", "mapped")); final ExtendedMetadataAndTags extendedMetadata2 = metadataList.get(1); assertThat(extendedMetadata2.getMetadata().getDescription()).isEqualTo("Description BufferPool-direct"); assertThat(extendedMetadata2.getMetadata().getDisplayName()).isEqualTo("Display Name BufferPool-direct"); assertThat(extendedMetadata2.getMetadata().getMbean()).isEqualTo("java.nio:name=direct,type=BufferPool/ObjectName"); assertThat(extendedMetadata2.getTags()).contains( new Tag("type", "BufferPool"), new Tag("name", "direct")); }
Example 11
Source File: WriteApiTest.java From influxdb-client-java with MIT License | 5 votes |
@Test void listAsMoreBatchUnits() { mockServer.enqueue(createResponse("{}")); mockServer.enqueue(createResponse("{}")); mockServer.enqueue(createResponse("{}")); mockServer.enqueue(createResponse("{}")); writeApi = influxDBClient.getWriteApi(WriteOptions.builder().batchSize(1).build()); String record1 = "h2o_feet,location=coyote_creek level\\ description=\"feet 1\",water_level=1.0 1"; String record2 = "h2o_feet,location=coyote_creek level\\ description=\"feet 2\",water_level=2.0 2"; String record3 = "h2o_feet,location=coyote_creek level\\ description=\"feet 3\",water_level=3.0 3"; String record4 = "h2o_feet,location=coyote_creek level\\ description=\"feet 4\",water_level=4.0 4"; List<String> records = Lists.list(record1, record2, record3, record4); writeApi.writeRecords("b1", "org1", WritePrecision.NS, records); String body1 = getRequestBody(mockServer); Assertions.assertThat(body1).isEqualTo(record1); String body2 = getRequestBody(mockServer); Assertions.assertThat(body2).isEqualTo(record2); String body3 = getRequestBody(mockServer); Assertions.assertThat(body3).isEqualTo(record3); String body4 = getRequestBody(mockServer); Assertions.assertThat(body4).isEqualTo(record4); }
Example 12
Source File: CsvImportTest.java From kid-bank with Apache License 2.0 | 5 votes |
@Test public void singleRowPaymentShouldResultInSingleSpendTransaction() throws Exception { String csv = "01/04/2019,Payment, $(30.00),Share of Corsair headphones"; List<String> csvList = Lists.list(csv); List<Transaction> transactions = new CsvImporter().importFrom(csvList); assertThat(transactions) .usingElementComparatorIgnoringFields("id") .containsExactly( CsvImporter.createSpend(LocalDateTime.of(2019, 1, 4, 0, 0), 3000, "Share of Corsair headphones")); }
Example 13
Source File: CsvImportTest.java From kid-bank with Apache License 2.0 | 5 votes |
@Test public void singleRowInterestCreditShouldResultInSingleInterestCreditTransaction() throws Exception { String csv = "02/01/2018,Interest Credit, $0.08 ,Interest based on 2%/year"; List<String> csvList = Lists.list(csv); List<Transaction> transactions = new CsvImporter().importFrom(csvList); assertThat(transactions) .usingElementComparatorIgnoringFields("id") .containsExactly( Transaction.createInterestCredit(LocalDateTime.of(2018, 2, 1, 0, 0), 8)); }
Example 14
Source File: CsvImportTest.java From kid-bank with Apache License 2.0 | 5 votes |
@Test public void singleRowDepositShouldResultInSingleDepositTransaction() throws Exception { String csv = "01/05/2018,Cash Deposit, $50.00 ,Birthday gift"; List<String> csvList = Lists.list(csv); List<Transaction> transactions = new CsvImporter().importFrom(csvList); assertThat(transactions) .usingElementComparatorIgnoringFields("id") .containsExactly( CsvImporter.createDeposit(LocalDateTime.of(2018, 1, 5, 0, 0), 5000, "Birthday gift")); }
Example 15
Source File: ImmutableAcknowledgementsTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@BeforeClass public static void setUpClass() { knownAcknowledgements = Lists.list(KNOWN_ACK_1, KNOWN_ACK_2); knownAcknowledgementsJsonRepresentation = knownAcknowledgements.stream() .map(ack -> JsonField.newInstance(ack.getLabel(), ack.toJson())) .collect(JsonCollectors.fieldsToObject()); knownAcknowledgementsGetEntityJsonRepresentation = knownAcknowledgements.stream() .map(ack -> JsonField.newInstance(ack.getLabel(), JsonObject.newBuilder() .set(Acknowledgement.JsonFields.STATUS_CODE, ack.getStatusCode().toInt()) .set(Acknowledgement.JsonFields.PAYLOAD, ack.getEntity().get()) .set(Acknowledgement.JsonFields.DITTO_HEADERS, ack.getDittoHeaders().toJson()) .build()) ) .collect(JsonCollectors.fieldsToObject()); knownJsonRepresentation = JsonObject.newBuilder() .set(Acknowledgements.JsonFields.ENTITY_ID, KNOWN_ENTITY_ID.toString()) .set(Acknowledgements.JsonFields.ENTITY_TYPE, KNOWN_ENTITY_ID.getEntityType().toString()) .set(Acknowledgements.JsonFields.STATUS_CODE, KNOWN_STATUS_CODE.toInt()) .set(Acknowledgements.JsonFields.ACKNOWLEDGEMENTS, knownAcknowledgementsJsonRepresentation) .set(Acknowledgements.JsonFields.DITTO_HEADERS, KNOWN_DITTO_HEADERS.toJson()) .build(); knownAcknowledgementsWith2Acks = ImmutableAcknowledgements.of(knownAcknowledgements, KNOWN_DITTO_HEADERS); }
Example 16
Source File: ThingsSseRouteBuilderTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void getWithAcceptHeaderAndNamespacesParameterOpensSseConnection() { final Collection<String> namespaces = Lists.list("john", "frum", "tanna"); final String requestUrl = THINGS_ROUTE + "?namespaces=" + String.join(",", namespaces); executeThingsRouteTest(HttpRequest.GET(requestUrl).addHeader(acceptHeader), StartStreaming.getBuilder(StreamingType.EVENTS, connectionCorrelationId, AuthorizationModelFactory.newAuthContext(DittoAuthorizationContextType.UNSPECIFIED, Collections.emptySet())) .withNamespaces(namespaces) .build()); }
Example 17
Source File: ImmutableAcknowledgementsTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void getStatusCodeWithMultipleItemsWithDivergentStatusCodes() { final Acknowledgement otherAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, KNOWN_ENTITY_ID, HttpStatusCode.CONFLICT, KNOWN_DITTO_HEADERS, null); final List<Acknowledgement> acknowledgements = Lists.list(KNOWN_ACK_1, otherAcknowledgement); final ImmutableAcknowledgements underTest = ImmutableAcknowledgements.of(acknowledgements, KNOWN_DITTO_HEADERS); assertThat(underTest.getStatusCode()).isEqualTo(HttpStatusCode.FAILED_DEPENDENCY); }
Example 18
Source File: ImmutableAcknowledgementsTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void getMissingAcknowledgementLabelsReturnsExpected() { final Acknowledgement timeoutAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, KNOWN_ENTITY_ID, HttpStatusCode.REQUEST_TIMEOUT, KNOWN_DITTO_HEADERS, null); final List<Acknowledgement> acknowledgements = Lists.list(KNOWN_ACK_1, timeoutAcknowledgement); final ImmutableAcknowledgements underTest = ImmutableAcknowledgements.of(acknowledgements, KNOWN_DITTO_HEADERS); assertThat(underTest.getMissingAcknowledgementLabels()).containsOnly(timeoutAcknowledgement.getLabel()); }
Example 19
Source File: ImmutableAcknowledgementsTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void getSuccessfulAcknowledgementsReturnsExpected() { final Acknowledgement timeoutAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, KNOWN_ENTITY_ID, HttpStatusCode.REQUEST_TIMEOUT, KNOWN_DITTO_HEADERS, null); final Acknowledgement successfulAcknowledgement = KNOWN_ACK_1; final List<Acknowledgement> acknowledgements = Lists.list(successfulAcknowledgement, timeoutAcknowledgement); final ImmutableAcknowledgements underTest = ImmutableAcknowledgements.of(acknowledgements, KNOWN_DITTO_HEADERS); assertThat(underTest.getSuccessfulAcknowledgements()).containsOnly(successfulAcknowledgement); }
Example 20
Source File: ImmutableAcknowledgementsTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void getFailedAcknowledgementsReturnsExpected() { final Acknowledgement timeoutAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, KNOWN_ENTITY_ID, HttpStatusCode.REQUEST_TIMEOUT, KNOWN_DITTO_HEADERS, null); final Acknowledgement failedAcknowledgement = ImmutableAcknowledgement.of(DittoAcknowledgementLabel.TWIN_PERSISTED, KNOWN_ENTITY_ID, HttpStatusCode.NOT_FOUND, KNOWN_DITTO_HEADERS, null); final List<Acknowledgement> acknowledgements = Lists.list(KNOWN_ACK_1, timeoutAcknowledgement, failedAcknowledgement); final ImmutableAcknowledgements underTest = ImmutableAcknowledgements.of(acknowledgements, KNOWN_DITTO_HEADERS); assertThat(underTest.getFailedAcknowledgements()).containsOnly(timeoutAcknowledgement, failedAcknowledgement); }