List of usage examples for com.google.common.collect ImmutableMultiset size
int size();
From source file:com.facebook.presto.tests.QueryAssertions.java
public static void assertEqualsIgnoreOrder(Iterable<?> actual, Iterable<?> expected) { assertNotNull(actual, "actual is null"); assertNotNull(expected, "expected is null"); ImmutableMultiset<?> actualSet = ImmutableMultiset.copyOf(actual); ImmutableMultiset<?> expectedSet = ImmutableMultiset.copyOf(expected); if (!actualSet.equals(expectedSet)) { fail(format("not equal\nActual %s rows:\n %s\nExpected %s rows:\n %s\n", actualSet.size(), Joiner.on("\n ").join(Iterables.limit(actualSet, 100)), expectedSet.size(), Joiner.on("\n ").join(Iterables.limit(expectedSet, 100)))); }//from w w w . j a v a2 s. c o m }
From source file:io.prestosql.tests.QueryAssertions.java
public static void assertEqualsIgnoreOrder(Iterable<?> actual, Iterable<?> expected, String message) { assertNotNull(actual, "actual is null"); assertNotNull(expected, "expected is null"); ImmutableMultiset<?> actualSet = ImmutableMultiset.copyOf(actual); ImmutableMultiset<?> expectedSet = ImmutableMultiset.copyOf(expected); if (!actualSet.equals(expectedSet)) { Multiset<?> unexpectedRows = Multisets.difference(actualSet, expectedSet); Multiset<?> missingRows = Multisets.difference(expectedSet, actualSet); int limit = 100; fail(format(/*w w w. j a va 2 s . com*/ "%snot equal\n" + "Actual rows (up to %s of %s extra rows shown, %s rows in total):\n %s\n" + "Expected rows (up to %s of %s missing rows shown, %s rows in total):\n %s\n", message == null ? "" : (message + "\n"), limit, unexpectedRows.size(), actualSet.size(), Joiner.on("\n ").join(Iterables.limit(unexpectedRows, limit)), limit, missingRows.size(), expectedSet.size(), Joiner.on("\n ").join(Iterables.limit(missingRows, limit)))); } }
From source file:fr.obeo.emf.specimen.SpecimenGenerator.java
private void generateSingleContainmentReference(EObject eObject, EReference eReference, ListMultimap<EClass, EObject> indexByKind, ImmutableMultiset<EClass> eAllConcreteSubTypesOrSelf) { IntegerDistribution distribution = c.getDistributionFor(eReference); if (booleanInDistribution(distribution)) { int idx = generator.nextInt(eAllConcreteSubTypesOrSelf.size()); final Optional<EObject> nextEObject = generateEObject(get(eAllConcreteSubTypesOrSelf, idx), indexByKind);/*from w w w .ja v a 2s .c om*/ if (nextEObject.isPresent()) { eObject.eSet(eReference, nextEObject.get()); } } }
From source file:fr.obeo.emf.specimen.SpecimenGenerator.java
private void generateManyContainmentReference(EObject eObject, EReference eReference, ListMultimap<EClass, EObject> indexByKind, ImmutableMultiset<EClass> eAllConcreteSubTypesOrSelf) { IntegerDistribution distribution = c.getDistributionFor(eReference); List<EObject> values = (List<EObject>) eObject.eGet(eReference); int sample = distribution.sample(); for (int i = 0; i < sample; i++) { int idx = generator.nextInt(eAllConcreteSubTypesOrSelf.size()); final Optional<EObject> nextEObject = generateEObject(get(eAllConcreteSubTypesOrSelf, idx), indexByKind);//from www .j av a 2s .co m if (nextEObject.isPresent()) { values.add(nextEObject.get()); } } }
From source file:eu.opensourceprojects.mondo.benchmarks.transformationzoo.instantiator.SpecimenGenerator.java
private void generateSingleContainmentReference(EObject eObject, EReference eReference, ListMultimap<EClass, EObject> indexByKind, ImmutableMultiset<EClass> eAllConcreteSubTypesOrSelf) { // DONE look if the lowerbound is 1 IntegerDistribution distribution = c.getDistributionFor(eReference); if (eReference.getLowerBound() != 0 || booleanInDistribution(distribution)) {//eReference.getLowerBound() == 1 int idx = generator.nextInt(eAllConcreteSubTypesOrSelf.size()); final Optional<EObject> nextEObject = generateEObject(get(eAllConcreteSubTypesOrSelf, idx), indexByKind);// w w w . j av a 2 s . com if (nextEObject.isPresent()) { eObject.eSet(eReference, nextEObject.get()); } } }
From source file:fr.obeo.emf.specimen.DirectWriteSpecimenGenerator.java
protected void generateSingleContainmentReference(EObject eObject, EReference eReference, ListMultimap<EClass, String> indexByKind, ImmutableMultiset<EClass> eAllConcreteSubTypesOrSelf) { IntegerDistribution distribution = configuration.getDistributionFor(eReference); if (eReference.isRequired() || booleanInDistribution(distribution)) { LOGGER.fine(MessageFormat.format("Generating EReference ''{0}'' in EObject {1}", eReference.getName(), eObject.toString()));/*from w w w.j a v a 2s. c o m*/ int idx = generator.nextInt(eAllConcreteSubTypesOrSelf.size()); final Optional<EObject> nextEObject = generateEObject(get(eAllConcreteSubTypesOrSelf, idx), indexByKind); if (nextEObject.isPresent()) { eObject.eSet(eReference, nextEObject.get()); } } }
From source file:fr.inria.atlanmod.instantiator.SpecimenGenerator.java
private void generateSingleContainmentReference(EObject eObject, EReference eReference, ListMultimap<EClass, EObject> indexByKind, ImmutableMultiset<EClass> eAllConcreteSubTypesOrSelf) { // DONE look if the lowerbound is 1 UniformLongDistribution distribution = c.getDistributionFor(eReference); if (eReference.getLowerBound() != 0 || booleanInDistribution(distribution)) {// eReference.getLowerBound() // ==//from www. j a v a 2 s. c om // 1 int idx = generator.nextInt(eAllConcreteSubTypesOrSelf.size()); final Optional<EObject> nextEObject = generateEObject(Iterables.get(eAllConcreteSubTypesOrSelf, idx), indexByKind); if (nextEObject.isPresent()) { eObject.eSet(eReference, nextEObject.get()); } } }
From source file:eu.opensourceprojects.mondo.benchmarks.transformationzoo.instantiator.SpecimenGenerator.java
private void generateManyContainmentReference(EObject eObject, EReference eReference, ListMultimap<EClass, EObject> indexByKind, ImmutableMultiset<EClass> eAllConcreteSubTypesOrSelf) { // DONE look if the lowerbound is 1 IntegerDistribution distribution = c.getDistributionFor(eReference); @SuppressWarnings("unchecked") List<EObject> values = (List<EObject>) eObject.eGet(eReference); int sample;//from w w w. j a v a2s. c om do { sample = distribution.sample(); } while (sample < eReference.getLowerBound()); for (int i = 0; i < sample; i++) { int idx = generator.nextInt(eAllConcreteSubTypesOrSelf.size()); final Optional<EObject> nextEObject = generateEObject(get(eAllConcreteSubTypesOrSelf, idx), indexByKind); if (nextEObject.isPresent()) { values.add(nextEObject.get()); } } }
From source file:fr.obeo.emf.specimen.DirectWriteSpecimenGenerator.java
protected void generateManyContainmentReference(EObject eObject, EReference eReference, ListMultimap<EClass, String> indexByKind, ImmutableMultiset<EClass> eAllConcreteSubTypesOrSelf) { IntegerDistribution distribution = configuration.getDistributionFor(eReference); @SuppressWarnings("unchecked") List<EObject> values = (List<EObject>) eObject.eGet(eReference); int sample = distribution.sample(); LOGGER.fine(MessageFormat.format("Generating {0} values for EReference ''{1}'' in EObject {2}", sample, eReference.getName(), eObject.toString())); for (int i = 0; i < sample; i++) { int idx = generator.nextInt(eAllConcreteSubTypesOrSelf.size()); final Optional<EObject> nextEObject = generateEObject(get(eAllConcreteSubTypesOrSelf, idx), indexByKind);/*w w w . ja va 2 s.co m*/ if (nextEObject.isPresent()) { values.add(nextEObject.get()); } } }
From source file:fr.inria.atlanmod.instantiator.SpecimenGenerator.java
private void generateManyContainmentReference(EObject eObject, EReference eReference, ListMultimap<EClass, EObject> indexByKind, ImmutableMultiset<EClass> eAllConcreteSubTypesOrSelf) { // DONE look if the lowerbound is 1 UniformLongDistribution distribution = c.getDistributionFor(eReference); @SuppressWarnings("unchecked") List<EObject> values = (List<EObject>) eObject.eGet(eReference); long sample;//from www . j a v a 2 s. c o m do { sample = distribution.sample(); } while (sample < eReference.getLowerBound()); for (int i = 0; i < sample; i++) { int idx = generator.nextInt(eAllConcreteSubTypesOrSelf.size()); final Optional<EObject> nextEObject = generateEObject(Iterables.get(eAllConcreteSubTypesOrSelf, idx), indexByKind); if (nextEObject.isPresent()) { values.add(nextEObject.get()); } } }