private void assertTwoTriggerInstanceListsEqual(final List<TriggerInstance> actual, final List<TriggerInstance> expected, final boolean ignoreFlowTrigger, final boolean keepOriginalOrder) { if (!keepOriginalOrder) { expected.sort(Comparator.comparing(TriggerInstance::getId)); actual.sort(Comparator.comparing(TriggerInstance::getId)); } assertThat(actual).hasSameSizeAs(expected); final Iterator<TriggerInstance> it1 = actual.iterator(); final Iterator<TriggerInstance> it2 = expected.iterator(); while (it1.hasNext() && it2.hasNext()) { //8bfafb89-ac79-45a0-a049-b55038b0886b assertTriggerInstancesEqual(it1.next(), it2.next(), ignoreFlowTrigger); } }
@Test void initializeRemoteConfig() throws Exception { InitializrMetadata localMetadata = this.metadataProvider.get(); InitializrMetadata metadata = InitializrMetadataBuilder.create() .withInitializrMetadata(new UrlResource(createUrl("/metadata/config"))) .build(); // Basic assertions assertThat(metadata.getDependencies().getContent()) .hasSameSizeAs(localMetadata.getDependencies().getContent()); assertThat(metadata.getTypes().getContent()) .hasSameSizeAs(localMetadata.getTypes().getContent()); assertThat(metadata.getBootVersions().getContent()) .hasSameSizeAs(localMetadata.getBootVersions().getContent()); assertThat(metadata.getPackagings().getContent()) .hasSameSizeAs(localMetadata.getPackagings().getContent()); assertThat(metadata.getJavaVersions().getContent()) .hasSameSizeAs(localMetadata.getJavaVersions().getContent()); assertThat(metadata.getLanguages().getContent()) .hasSameSizeAs(localMetadata.getLanguages().getContent()); }
@Test public void testUploadTriggerInstance() { final TriggerInstance expectedTriggerInst = this.createTriggerInstance(this.flowTrigger, this .flow_id, this.flow_version, this.submitUser, this.project, System.currentTimeMillis()); this.triggerInstLoader.uploadTriggerInstance(expectedTriggerInst); final TriggerInstance actualTriggerInst = this.triggerInstLoader .getTriggerInstanceById(expectedTriggerInst.getId()); assertThat(expectedTriggerInst.getFlowTrigger().toString()) .isEqualToIgnoringWhitespace(actualTriggerInst.getFlowTrigger().toString()); assertThat(expectedTriggerInst).isEqualToIgnoringGivenFields(actualTriggerInst, "depInstances", "flowTrigger"); assertThat(expectedTriggerInst.getDepInstances()) .usingElementComparatorIgnoringFields("triggerInstance", "context") .containsAll(actualTriggerInst.getDepInstances()) .hasSameSizeAs(actualTriggerInst.getDepInstances()); }
@Test public void testListCollections() throws Exception { List<String> collections = Arrays.asList("coll1", "coll2", "coll3"); for (String collection : collections) { getCollection(collection).insertOne(json("_id: 1")); } Document result = db.runCommand(json("listCollections: 1")); assertThat(result.getDouble("ok")).isEqualTo(1.0); Document cursor = (Document) result.get("cursor"); assertThat(cursor.keySet()).containsExactly("id", "ns", "firstBatch"); assertThat(cursor.get("id")).isEqualTo(Long.valueOf(0)); assertThat(cursor.get("ns")).isEqualTo(db.getName() + ".$cmd.listCollections"); assertThat(cursor.get("firstBatch")).isInstanceOf(List.class); @SuppressWarnings("unchecked") List<Document> firstBatch = (List<Document>) cursor.get("firstBatch"); assertThat(firstBatch).hasSameSizeAs(collections); Set<String> collectionNames = new HashSet<>(); for (Document collection : firstBatch) { assertThat(collection.keySet()).containsExactlyInAnyOrder("name", "options", "type", "idIndex", "info"); String name = (String) collection.get("name"); assertThat(collection.get("options")).isEqualTo(json("")); assertThat(collection.get("name")).isInstanceOf(String.class); assertThat(collection.get("type")).isEqualTo("collection"); assertThat(collection.get("idIndex")).isEqualTo(json("key: {_id: 1}, name: '_id_', ns: 'testdb." + name + "', v: 2")); assertThat(collection.get("info")).isInstanceOf(Document.class); collectionNames.add(name); } assertThat(collectionNames).containsExactlyInAnyOrderElementsOf(collections); }
private Executable Should_Return_All_Permutations(final TestCase testCase) { return () -> { // given final List<Field> fields = TestHelper.getAllFieldsExceptDummyJacocoField(testCase.clazz); // when final List<List<Field>> permutations = FieldUtils.permutations(fields); // then assertThat(permutations).hasSameSizeAs(testCase.fields) .containsAll(testCase.fields); }; }
@Test public void createMultipleUpdateActions() throws Exception { final List<String> contentList = generateAsStrings(MyResource.class); final List<String> expectedContent = expectedContent(MyResource.class); assertThat(contentList).hasSameSizeAs(expectedContent); for (int index = 0; index < contentList.size(); index++) { assertThat(contentList.get(index)).isEqualTo(expectedContent.get(index)); } }
@Test public void testAddAddressesToCartUpdateAction() { final List<Address> addressList = createAddressArray(); withFilledCart(client(), cart -> { assertThat(cart.getItemShippingAddresses()).isEmpty(); List<UpdateAction<Cart>> addAddresses = addressList.stream().map(AddItemShippingAddress::of).collect(Collectors.toList()); Cart updatedCart = client().executeBlocking(CartUpdateCommand.of(cart,addAddresses )); assertThat(updatedCart.getItemShippingAddresses()).hasSameSizeAs(addressList); }); }
@Test public void testAddAddressesToCartUpdateAction() { final List<Address> addressList = createAddressArray(); withFilledCart(client(), cart -> { withCustomer(client(),customer -> { withOrder(client(),customer,cart,order -> { assertThat(order.getItemShippingAddresses()).isEmpty(); List<UpdateAction<Order>> addAddresses = addressList.stream().map(AddItemShippingAddress::of).collect(Collectors.toList()); Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order,addAddresses )); assertThat(updatedOrder.getItemShippingAddresses()).hasSameSizeAs(addressList); return updatedOrder; }); }); }); }
@Test public void testSetCustomLineItemShippingDetails() { final List<Address> addressList = createAddressArray(); withOrderOfCustomLineItems(client(),order -> { assertThat(order.getItemShippingAddresses()).isEmpty(); List<UpdateAction<Order>> addAddresses = addressList.stream().map(AddItemShippingAddress::of).collect(Collectors.toList()); Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order,addAddresses )); assertThat(updatedOrder.getItemShippingAddresses()).hasSameSizeAs(addressList); assertThat(order.getCustomLineItems()).isNotEmpty(); final CustomLineItem firstLineItem = updatedOrder.getCustomLineItems().get(0); final Long quantity = firstLineItem.getQuantity(); final List<Address> addresses = updatedOrder.getItemShippingAddresses(); final Address firstAddress = addresses.get(0); final String firstAddressKey = firstAddress.getKey(); final ItemShippingDetailsDraft itemShippingDetailsDraft = ItemShippingDetailsDraftBuilder.of(Arrays.asList(ItemShippingTargetBuilder.of(firstAddressKey, firstLineItem.getQuantity()).build())).build(); final Order updatedOrder2 = client().executeBlocking(OrderUpdateCommand.of(updatedOrder, SetCustomLineItemShippingDetails.of(firstLineItem.getId(),itemShippingDetailsDraft))); final CustomLineItem updatedLineItem = updatedOrder2.getCustomLineItems().stream().filter(lineItem -> lineItem.getId().equals(firstLineItem.getId())).findAny().get(); assertThat(updatedLineItem.getShippingDetails().getTargets()).hasSize(1); assertThat(updatedLineItem.getShippingDetails().getTargets().get(0).getAddressKey()).isEqualTo(firstAddressKey); assertThat(updatedLineItem.getShippingDetails().getTargets().get(0).getQuantity()).isEqualTo(quantity); } ); }
assertThat(viewNodes).hasSameSizeAs(nodes); assertThat(viewNodeInstances).hasSameSizeAs(nodeInstances); assertThat(viewTimerInstances).hasSameSizeAs(timerInstances);
ServiceDocumentQueryResult.class); assertThat(templateResult.documentLinks).hasSameSizeAs(templateResult.documents.keySet());
ServiceDocumentQueryResult.class); assertThat(templateResult.documentLinks).hasSameSizeAs(templateResult.documents.keySet());
assertThat(generated).isEqualToIgnoringGivenFields(expected, "id", "icon", "properties", "configuredProperties", "actions"); assertThat(generated.getIcon()).startsWith("data:image"); assertThat(generated.getActions()).hasSameSizeAs(expected.getActions());
assertThat(generated).isEqualToIgnoringGivenFields(expected, "id", "icon", "properties", "configuredProperties", "actions"); assertThat(generated.getIcon()).startsWith("data:image"); assertThat(generated.getActions()).hasSameSizeAs(expected.getActions());
assertThat(generated).isEqualToIgnoringGivenFields(expected, "id", "icon", "properties", "configuredProperties", "actions"); assertThat(generated.getIcon()).startsWith("data:image"); assertThat(generated.getActions()).hasSameSizeAs(expected.getActions());