src_fm_fc_ms_ff stringlengths 43 86.8k | target stringlengths 20 276k |
|---|---|
Asyncs { public static Async<Void> parallel(Async<?>... asyncs) { return parallel(Arrays.asList(asyncs)); } private Asyncs(); static boolean isFinished(Async<?> async); static Async<ValueT> constant(final ValueT val); static Async<ValueT> failure(final Throwable t); static Async<Void> toVoid(Async<ResultT> a); static ... | @Test public void emptyParallel() { assertThat(Asyncs.parallel(), voidSuccess()); } |
Asyncs { @GwtIncompatible public static <ItemT> Async<List<ItemT>> parallelResult(Collection<Async<ItemT>> asyncs) { final List<ItemT> result = Collections.synchronizedList(new ArrayList<ItemT>()); for (Async<ItemT> async : asyncs) { async.onSuccess( new Consumer<ItemT>() { @Override public void accept(ItemT item) { re... | @Test public void parallelResult() { assertThat( Asyncs.parallelResult(Arrays.asList( Asyncs.constant(1), Asyncs.<Integer>failure(new Throwable()), Asyncs.constant(2) )), result(equalTo(Arrays.asList(1, 2))) ); } |
Rectangle { public boolean intersects(Rectangle rect) { Vector t1 = origin; Vector t2 = origin.add(dimension); Vector r1 = rect.origin; Vector r2 = rect.origin.add(rect.dimension); return r2.x >= t1.x && t2.x >= r1.x && r2.y >= t1.y && t2.y >= r1.y; } Rectangle(Vector origin, Vector dimension); Rectangle(int x, int y,... | @Test public void intersects() { assertFalse(new Rectangle(0, 0, 1, 1).intersects(new Rectangle(2, 2, 1, 1))); assertTrue(new Rectangle(0, 0, 2, 2).intersects(new Rectangle(1, 1, 2, 2))); } |
Asyncs { public static <ResultT> Async<ResultT> untilSuccess(final Supplier<Async<ResultT>> s) { final SimpleAsync<ResultT> result = new SimpleAsync<>(); Async<ResultT> async; final Consumer<ResultT> successConsumer = new Consumer<ResultT>() { @Override public void accept(ResultT item) { result.success(item); } }; try ... | @Test public void untilSuccess() { assertThat( Asyncs.untilSuccess(new Supplier<Async<Integer>>() { @Override public Async<Integer> get() { return Asyncs.constant(1); } }), result(equalTo(1))); } |
Persisters { public static Persister<Integer> intPersister() { return INT_PERSISTER; } private Persisters(); static Persister<String> stringPersister(); static Persister<Integer> intPersister(); static Persister<Integer> intPersister(final int defaultValue); static Persister<E> enumPersister(final Class<E> cls, final ... | @Test public void nullInt() { testNull(Persisters.intPersister(10)); } |
Persisters { public static Persister<Long> longPersister() { return LONG_PERSISTER; } private Persisters(); static Persister<String> stringPersister(); static Persister<Integer> intPersister(); static Persister<Integer> intPersister(final int defaultValue); static Persister<E> enumPersister(final Class<E> cls, final E... | @Test public void nullLong() { testNull(Persisters.longPersister()); } |
Persisters { public static Persister<Boolean> booleanPersister() { return BOOLEAN_PERSISTER; } private Persisters(); static Persister<String> stringPersister(); static Persister<Integer> intPersister(); static Persister<Integer> intPersister(final int defaultValue); static Persister<E> enumPersister(final Class<E> cls... | @Test public void nullBoolean() { testNull(Persisters.booleanPersister(true)); } |
Persisters { public static Persister<Double> doublePersister() { return DOUBLE_PERSISTER; } private Persisters(); static Persister<String> stringPersister(); static Persister<Integer> intPersister(); static Persister<Integer> intPersister(final int defaultValue); static Persister<E> enumPersister(final Class<E> cls, f... | @Test public void nullDouble() { testNull(Persisters.doublePersister(1.5)); } |
Persisters { public static Persister<String> stringPersister() { return STRING_PERSISTER; } private Persisters(); static Persister<String> stringPersister(); static Persister<Integer> intPersister(); static Persister<Integer> intPersister(final int defaultValue); static Persister<E> enumPersister(final Class<E> cls, f... | @Test public void nullString() { Persister<String> persister = Persisters.stringPersister(); assertNull(persister.deserialize(persister.serialize(null))); } |
Interval { public boolean contains(int point) { return myLowerBound <= point && point <= myUpperBound; } Interval(int lowerBound, int upperBound); int getLowerBound(); int getUpperBound(); int getLength(); boolean contains(int point); boolean contains(Interval other); boolean intersects(Interval other); Interval union(... | @Test public void contains() { checkContains(i_1_4); checkContains(2, 3); checkContains(1, 2); checkContains(3, 4); checkNotContains(0, 4); checkNotContains(1, 5); checkNotContains(0, 5); checkNotContains(4, 10); } |
Interval { public boolean intersects(Interval other) { return contains(other.getLowerBound()) || other.contains(getLowerBound()); } Interval(int lowerBound, int upperBound); int getLowerBound(); int getUpperBound(); int getLength(); boolean contains(int point); boolean contains(Interval other); boolean intersects(Inter... | @Test public void intersects() { checkIntersects(i_1_4); checkIntersects(2, 3); checkIntersects(1, 2); checkIntersects(3, 4); checkIntersects(0, 4); checkIntersects(0, 1); checkIntersects(2, 5); checkIntersects(4, 5); checkIntersects(0, 5); checkNotIntersects(-1, 0); checkNotIntersects(5, 6); } |
Interval { public Interval union(Interval other) { return new Interval(Math.min(myLowerBound, other.myLowerBound), Math.max(myUpperBound, other.myUpperBound)); } Interval(int lowerBound, int upperBound); int getLowerBound(); int getUpperBound(); int getLength(); boolean contains(int point); boolean contains(Interval ot... | @Test public void union() { checkUnion(i(1, 2), i(3, 4)); checkUnion(i(1, 3), i(2, 4)); checkUnion(i(3, 4), i(1, 2)); checkUnion(i(2, 4), i(1, 3)); checkUnion(i_1_4, i(2, 3)); checkUnion(i(2, 3), i_1_4); } |
Interval { public Interval add(int delta) { return new Interval(myLowerBound + delta, myUpperBound + delta); } Interval(int lowerBound, int upperBound); int getLowerBound(); int getUpperBound(); int getLength(); boolean contains(int point); boolean contains(Interval other); boolean intersects(Interval other); Interval ... | @Test public void add() { checkAdd(i(0, 3), 1); checkAdd(i_1_4, 0); checkAdd(i(2, 5), -1); } |
Rectangle { public Rectangle intersect(Rectangle r) { if (!intersects(r)) { throw new IllegalStateException("rectangle [" + this + "] doesn't intersect [" + r + "]"); } Vector too = origin.add(dimension); Vector roo = r.origin.add(r.dimension); Vector ioo = too.min(roo); Vector io = origin.max(r.origin); return new Rec... | @Test public void intersection() { assertEquals(new Rectangle(1, 1, 1, 1), new Rectangle(0, 0, 2, 2).intersect(new Rectangle(1, 1, 2, 2))); assertEquals(new Rectangle(1, 1, 2, 2), new Rectangle(0, 0, 3, 3).intersect(new Rectangle(1, 1, 2, 2))); } |
Interval { public Interval sub(int delta) { return new Interval(myLowerBound - delta, myUpperBound - delta); } Interval(int lowerBound, int upperBound); int getLowerBound(); int getUpperBound(); int getLength(); boolean contains(int point); boolean contains(Interval other); boolean intersects(Interval other); Interval ... | @Test public void sub() { checkSub(i(0, 3), -1); checkSub(i_1_4, 0); checkSub(i(2, 5), 1); } |
ThrowableHandlers { static void handleError(Throwable t) { if (isClient(t)) { return; } Error error = getError(t); if (error != null) { throw error; } } private ThrowableHandlers(); static Registration addHandler(Consumer<? super Throwable> handler); static void asInProduction(Runnable r); static void handle(Throwable... | @Test public void handleClientException() { ThrowableHandlers.handleError(createGwtException()); }
@Test public void handleClientError() { ThrowableHandlers.handleError(createGwtError()); }
@Test public void handleClientInnerError() { ThrowableHandlers.handleError(new RuntimeException(createGwtError())); }
@Test public... |
RunningEdtManager implements EdtManager, EventDispatchThread { @Override public final void schedule(Runnable r) { checkCanSchedule(); doSchedule(r); } RunningEdtManager(); RunningEdtManager(String name); @Override EventDispatchThread getEdt(); @Override final void finish(); @Override final void kill(); @Override long ... | @Test public void exceptionInTask() { ThrowableHandlers.asInProduction(new Runnable() { @Override public void run() { manager.schedule(new Runnable() { @Override public void run() { throw new RuntimeException(); } }); } }); final Value<Boolean> taskCompleted = new Value<>(false); manager.schedule(new Runnable() { @Over... |
EdtManagerPool implements EdtManagerFactory { boolean checkManager(EdtManager manager) { synchronized (myLock) { EdtManagerAdapter adapter = (EdtManagerAdapter) manager; return adapter.myManager == myManagers[adapter.myIndex]; } } EdtManagerPool(String name, int poolSize, EdtManagerFactory factory); @Override EdtManage... | @Test public void checkManager() { init(); EdtManager temp1 = createManager(); EdtManager checking = createManager(); temp1.finish(); EdtManager temp2 = createManager(); assertTrue(pool.checkManager(checking)); } |
ExecutorEdtManager implements EdtManager, EventDispatchThread { @Override public void finish() { ensureCanShutdown(); myEdt.getExecutor().shutdown(); waitTermination(); } ExecutorEdtManager(); ExecutorEdtManager(String name); @Override EventDispatchThread getEdt(); @Override void finish(); @Override void kill(); @Over... | @Test public void finishFromItself() { shutdownFromItself(new Consumer<EdtManager>() { @Override public void accept(EdtManager edtManager) { edtManager.finish(); } }); } |
Rectangle { public Rectangle union(Rectangle rect) { Vector newOrigin = origin.min(rect.origin); Vector corner = origin.add(dimension); Vector rectCorner = rect.origin.add(rect.dimension); Vector newCorner = corner.max(rectCorner); Vector newDimension = newCorner.sub(newOrigin); return new Rectangle(newOrigin, newDimen... | @Test public void union() { assertEquals(new Rectangle(0, 0, 3, 3), new Rectangle(0, 0, 1, 1).union(new Rectangle(2, 2, 1, 1))); } |
ExecutorEdtManager implements EdtManager, EventDispatchThread { @Override public void kill() { ensureCanShutdown(); myEdt.getExecutor().shutdownNow(); waitTermination(); } ExecutorEdtManager(); ExecutorEdtManager(String name); @Override EventDispatchThread getEdt(); @Override void finish(); @Override void kill(); @Ove... | @Test public void killFromItself() { shutdownFromItself(new Consumer<EdtManager>() { @Override public void accept(EdtManager edtManager) { edtManager.kill(); } }); } |
ListItemProperty extends BaseReadableProperty<ValueT> implements Property<ValueT>, Disposable { @Override public ValueT get() { if (isValid()) { return myList.get(getIndex().get()); } else { return null; } } ListItemProperty(ObservableList<ValueT> list, int index); @Override Registration addHandler(EventHandler<? super... | @Test public void getsTheRightItem() { ObservableList<Integer> list = createList(5); ListItemProperty<Integer> p2 = new ListItemProperty<>(list, 2); assertEquals(2, p2.get().intValue()); ListItemProperty<Integer> p4 = new ListItemProperty<>(list, 4); assertEquals(4, p4.get().intValue()); } |
ListItemProperty extends BaseReadableProperty<ValueT> implements Property<ValueT>, Disposable { @Override public void set(ValueT value) { if (isValid()) { myList.set(getIndex().get(), value); } else { throw new IllegalStateException("Property points to an invalid item, can’t set"); } } ListItemProperty(ObservableList<V... | @Test public void setsTheRightItem() { ObservableList<Integer> list = createList(5); ListItemProperty<Integer> p2 = new ListItemProperty<>(list, 2); p2.set(12); assertEquals("[0, 1, 12, 3, 4]", "" + list); ListItemProperty<Integer> p4 = new ListItemProperty<>(list, 4); p4.set(14); assertEquals("[0, 1, 12, 3, 14]", "" +... |
ListItemProperty extends BaseReadableProperty<ValueT> implements Property<ValueT>, Disposable { @Override public void dispose() { if (myDisposed) { throw new IllegalStateException("Double dispose"); } if (isValid()) { myReg.dispose(); } myDisposed = true; } ListItemProperty(ObservableList<ValueT> list, int index); @Ove... | @Test public void disposeImmediately() { p1.dispose(); exception.expect(IllegalStateException.class); p1.dispose(); }
@Test public void indexFiresNotOnDispose() { p1.dispose(); assertThat(p1indexHandler, noEvents()); }
@Test public void indexFiresNotOnDisposeInvalid() { list.remove(1); assertThat(p1indexHandler, allEve... |
UpdatableProperty extends BaseDerivedProperty<ValueT> { public void update() { somethingChanged(); } protected UpdatableProperty(); @Override String getPropExpr(); void update(); } | @Test public void updateFiresEvent() { EventHandler<? super PropertyChangeEvent<String>> handler = Mockito.mock(EventHandler.class); property.addHandler(handler); value = "z"; property.update(); Mockito.verify(handler).onEvent(new PropertyChangeEvent<>(null, "z")); }
@Test public void updateWithoutChangeDoesntFireEvent... |
Rectangle { @Override public int hashCode() { return origin.hashCode() * 31 + dimension.hashCode(); } Rectangle(Vector origin, Vector dimension); Rectangle(int x, int y, int width, int height); Rectangle add(Vector v); Rectangle sub(Vector v); boolean contains(Rectangle r); boolean contains(Vector v); Rectangle union(... | @Test public void hashCodeWorks() { assertEquals(new Rectangle(0, 0, 3, 3).hashCode(), new Rectangle(0, 0, 3, 3).hashCode()); } |
PropertyPersisters { public static <T> Persister<Property<T>> valuePropertyPersister(final Persister<T> itemPersister) { return new Persister<Property<T>>() { @Override public Property<T> deserialize(String value) { if (value == null) { return null; } if (!value.isEmpty() && value.charAt(0) == 'v') { return new ValuePr... | @Test public void nullStringValueProperty() { testNull(PropertyPersisters.valuePropertyPersister(stringPersister())); }
@Test public void valuePropertyEmptyString() { assertNull(PropertyPersisters.valuePropertyPersister(stringPersister()).deserialize("").get()); } |
PropertyBinding { public static <ValueT> Registration bindTwoWay(final Property<ValueT> source, final Property<ValueT> target) { final Property<Boolean> syncing = new ValueProperty<>(false); target.set(source.get()); class UpdatingEventHandler implements EventHandler<PropertyChangeEvent<ValueT>> { private boolean myFor... | @Test public void bidirectionalSync() { source.set("239"); Registration reg = PropertyBinding.bindTwoWay(source, target); assertEquals("239", target.get()); target.set("z"); assertEquals("z", source.get()); reg.remove(); source.set("zzz"); assertEquals("z", target.get()); } |
ListMap { @Override public String toString() { StringBuilder builder = new StringBuilder(); builder.append("{"); for (int i = 0; i < myData.length; i += 2) { @SuppressWarnings("unchecked") K k = (K) myData[i]; @SuppressWarnings("unchecked") V v = (V) myData[i + 1]; if (i != 0) { builder.append(","); } builder.append(k)... | @Test public void empty() { assertEquals("{}", list.toString()); } |
ListMap { public V put(K key, V value) { int index = findByKey(key); if (index >= 0) { @SuppressWarnings("unchecked") V oldValue = (V) myData[index + 1]; myData[index + 1] = value; return oldValue; } Object[] newArray = new Object[myData.length + 2]; System.arraycopy(myData, 0, newArray, 0, myData.length); newArray[myD... | @Test public void put() { list.put("a", "b"); assertEquals("{a=b}", list.toString()); } |
ListMap { public boolean isEmpty() { return size() == 0; } ListMap(); boolean containsKey(K key); V remove(K key); Set<K> keySet(); boolean isEmpty(); Collection<V> values(); Set<Entry> entrySet(); int size(); V put(K key, V value); V get(K key); @Override String toString(); } | @Test public void isEmpty() { assertTrue(list.isEmpty()); } |
ListMap { public boolean containsKey(K key) { return findByKey(key) >= 0; } ListMap(); boolean containsKey(K key); V remove(K key); Set<K> keySet(); boolean isEmpty(); Collection<V> values(); Set<Entry> entrySet(); int size(); V put(K key, V value); V get(K key); @Override String toString(); } | @Test public void containsKey() { list.put("a", "b"); assertTrue(list.containsKey("a")); } |
ObservableCollections { public static <ItemT> ReadableProperty<Integer> count( final ObservableCollection<ItemT> collection, final Predicate<? super ItemT> predicate) { return new BaseDerivedProperty<Integer>(simpleCount(predicate, collection)) { private Registration myCollectionRegistration; private int myCount; @Over... | @Test public void count() { ObservableList<String> collection = new ObservableArrayList<>(); ReadableProperty<Integer> count = ObservableCollections.count(collection, STARTS_WITH_A); runChanges(collection, count); }
@Test public void countListener() { ObservableList<String> collection = new ObservableArrayList<>(); Rea... |
Vector { @Override public boolean equals(Object obj) { if (!(obj instanceof Vector)) return false; Vector otherVector = (Vector) obj; return x == otherVector.x && y == otherVector.y; } Vector(int x, int y); Vector add(Vector v); Vector sub(Vector v); Vector negate(); Vector max(Vector v); Vector min(Vector v); Vector m... | @Test public void equals() { assertThat(new Vector(1, 2), is(new Vector(1, 2))); assertThat(new Vector(1, 2), is(not(new Vector(2, 1)))); } |
ObservableCollections { public static <ItemT> ReadableProperty<Boolean> all( final ObservableCollection<ItemT> collection, Predicate<? super ItemT> predicate) { return Properties.map(count(collection, predicate), new Function<Integer, Boolean>() { @Override public Boolean apply(Integer value) { return value == collecti... | @Test public void allTest() { ObservableCollection<String> collection = new ObservableArrayList<>(); ReadableProperty<Boolean> all = ObservableCollections.all(collection, STARTS_WITH_A); assertTrue(all.get()); collection.add("a"); assertTrue(all.get()); collection.add("b"); assertFalse(all.get()); collection.clear(); a... |
ObservableCollections { public static <ItemT> ReadableProperty<Boolean> any( ObservableCollection<ItemT> collection, Predicate<? super ItemT> predicate) { return Properties.map(count(collection, predicate), new Function<Integer, Boolean>() { @Override public Boolean apply(Integer value) { return value > 0; } }); } priv... | @Test public void anyTest() { ObservableCollection<String> collection = new ObservableArrayList<>(); ReadableProperty<Boolean> any = ObservableCollections.any(collection, STARTS_WITH_A); assertFalse(any.get()); collection.add("b"); assertFalse(any.get()); collection.add("a"); assertTrue(any.get()); collection.clear(); ... |
ObservableSetWrapper implements ObservableSet<TargetItemT> { @Override public boolean add(TargetItemT wrapper) { return mySource.add(myTtoS.apply(wrapper)); } ObservableSetWrapper(ObservableSet<SourceItemT> source, Function<SourceItemT, TargetItemT> toTarget, Function<TargetItemT, SourceItemT> toSource); @Override Regi... | @Test public void setMapAddSource() { source.add(15.0); assertThat(target, containsInAnyOrder(11, 16, 21, 31)); listener.assertEvents(1, 0); assertThat(listener.getAddEvents().get(0), is(addEvent(equalTo(16), equalTo(-1)))); }
@Test public void listMapAddTarget() { target.add(15); assertThat(target, containsInAnyOrder(... |
ObservableSetWrapper implements ObservableSet<TargetItemT> { @Override public boolean remove(Object o) { @SuppressWarnings("unchecked") TargetItemT targetItem = (TargetItemT) o; return mySource.remove(myTtoS.apply(targetItem)); } ObservableSetWrapper(ObservableSet<SourceItemT> source, Function<SourceItemT, TargetItemT>... | @Test public void setMapRemoveSource() { source.remove(30.0); assertThat(target, containsInAnyOrder(11, 21)); listener.assertEvents(0, 1); assertThat(listener.getRemoveEvents().get(0), is(removeEvent(equalTo(31), equalTo(-1)))); }
@Test public void setMapRemoveTarget() { target.remove(31); assertThat(target, containsIn... |
TreePath implements Comparable<TreePath<CompositeT>> { @Override public int compareTo(TreePath<CompositeT> o) { int maxIndex = Math.min(myPath.size(), o.myPath.size()); for (int i = 0; i < maxIndex; i++) { int delta = myPath.get(i) - o.myPath.get(i); if (delta != 0) return delta; } return myPath.size() - o.myPath.size(... | @Test public void pathComparison() { assertTrue(new TreePath<>(root).compareTo(new TreePath<>(child1)) < 0); assertTrue(new TreePath<>(child1).compareTo(new TreePath<>(child2)) < 0); assertEquals(0, new TreePath<>(child1).compareTo(new TreePath<>(child1))); } |
TreePath implements Comparable<TreePath<CompositeT>> { public static <CompositeT extends Composite<CompositeT>> void sort(List<? extends CompositeT> composites) { final Map<CompositeT, TreePath<CompositeT>> paths = new HashMap<>(); for (CompositeT composite : composites) { paths.put(composite, new TreePath<>(composite)... | @Test public void sortByPath() { List<TestComposite> composites = new ArrayList<>(Arrays.asList(child2, child1, root)); TreePath.sort(composites); assertEquals(Arrays.asList(root, child1, child2), composites); } |
TreePath implements Comparable<TreePath<CompositeT>> { public boolean isValid(CompositeT root) { CompositeT current = root; for (Integer i : myPath) { List<CompositeT> children = current.children(); if (i >= children.size()) { return false; } current = children.get(i); } return true; } TreePath(CompositeT composite); ... | @Test public void pathValidity() { TreePath<TestComposite> path = new TreePath<>(child1); assertTrue(path.isValid(root)); assertFalse(path.isValid(child1)); } |
Vector { public Vector add(Vector v) { return new Vector(x + v.x, y + v.y); } Vector(int x, int y); Vector add(Vector v); Vector sub(Vector v); Vector negate(); Vector max(Vector v); Vector min(Vector v); Vector mul(int i); Vector div(int i); int dotProduct(Vector v); double length(); DoubleVector toDoubleVector(); Vec... | @Test public void add() { assertThat(new Vector(1, 2).add(new Vector(1, 2)), is(new Vector(2, 4))); } |
AlphaNumericComparator implements Comparator { public int compare(Object o1, Object o2) { String s1 = o1.toString(); String s2 = o2.toString(); int n1 = s1.length(), n2 = s2.length(); int i1 = 0, i2 = 0; while (i1 < n1 && i2 < n2) { int p1 = i1; int p2 = i2; char c1 = s1.charAt(i1++); char c2 = s2.charAt(i2++); if(c1 !... | @Test public void testBasic() { Comparator c = new AlphaNumericComparator(); assertTrue(c.compare("a", "b") < 0); assertTrue(c.compare("shard1", "shard1") == 0); assertTrue(c.compare("shard10", "shard10") == 0); assertTrue(c.compare("shard1", "shard2") < 0); assertTrue(c.compare("shard9", "shard10") < 0); assertTrue(c.... |
User extends BaseExpression { public Result apply(PathData item) throws IOException { if(requiredUser.equals(getFileStatus(item).getOwner())) { return Result.PASS; } return Result.FAIL; } User(); @Override void addArguments(Deque<String> args); @Override void initialise(FindOptions options); Result apply(PathData item)... | @Test public void applyBlank() throws IOException { when(fileStatus.getOwner()).thenReturn(""); assertEquals(Result.FAIL, user.apply(item)); }
@Test public void applyNull() throws IOException { when(fileStatus.getOwner()).thenReturn(null); assertEquals(Result.FAIL, user.apply(item)); }
@Test public void applyPass() thr... |
Size extends NumberExpression { @Override public Result apply(PathData item) throws IOException { return applyNumber(getFileStatus(item).getLen()); } Size(); @Override Result apply(PathData item); static void registerExpression(ExpressionFactory factory); } | @Test public void applyEqualsBlock() throws IOException { Size size = new Size(); addArgument(size, "5"); size.initialise(new FindOptions()); assertEquals(Result.PASS, size.apply(fiveBlocks)); assertEquals(Result.FAIL, size.apply(sixBlocks)); assertEquals(Result.FAIL, size.apply(fourBlocks)); assertEquals(Result.PASS, ... |
And extends BaseExpression { @Override public void addChildren(Deque<Expression> expressions) { addChildren(expressions, 2); } And(); @Override Result apply(PathData item); @Override boolean isOperator(); @Override int getPrecedence(); @Override void addChildren(Deque<Expression> expressions); static void registerExpre... | @Test public void testInit() throws IOException { And and = new And(); Expression first = mock(Expression.class); Expression second = mock(Expression.class); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); and.addChildren(children); FindOptions options = mock(FindOp... |
FilterExpression implements Expression, Configurable { @Override public void initialise(FindOptions options) throws IOException { expression.initialise(options); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void fi... | @Test public void initialise() throws IOException { FindOptions options = mock(FindOptions.class); test.initialise(options); verify(expr).initialise(options); verifyNoMoreInteractions(expr); } |
Depth extends BaseExpression { @Override public void initialise(FindOptions options) { options.setDepth(true); } Depth(); @Override Result apply(PathData item); @Override void initialise(FindOptions options); static void registerExpression(ExpressionFactory factory); } | @Test public void initialise() throws IOException{ FindOptions options = new FindOptions(); Depth depth = new Depth(); assertFalse(options.isDepth()); depth.initialise(options); assertTrue(options.isDepth()); } |
FilterExpression implements Expression, Configurable { @Override public Result apply(PathData item) throws IOException { return expression.apply(item); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void finish(); @O... | @Test public void apply() throws IOException { PathData item = mock(PathData.class); when(expr.apply(item)).thenReturn(Result.PASS).thenReturn(Result.FAIL); assertEquals(Result.PASS, test.apply(item)); assertEquals(Result.FAIL, test.apply(item)); verify(expr, times(2)).apply(item); verifyNoMoreInteractions(expr); } |
FilterExpression implements Expression, Configurable { @Override public void finish() throws IOException { expression.finish(); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void finish(); @Override String[] getUsag... | @Test public void finish() throws IOException { test.finish(); verify(expr).finish(); verifyNoMoreInteractions(expr); } |
FilterExpression implements Expression, Configurable { @Override public String[] getUsage() { return expression.getUsage(); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void finish(); @Override String[] getUsage();... | @Test public void getUsage() { String[] usage = new String[]{"Usage 1", "Usage 2", "Usage 3"}; when(expr.getUsage()).thenReturn(usage); assertArrayEquals(usage, test.getUsage()); verify(expr).getUsage(); verifyNoMoreInteractions(expr); } |
FilterExpression implements Expression, Configurable { @Override public String[] getHelp() { return expression.getHelp(); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void finish(); @Override String[] getUsage(); @... | @Test public void getHelp() { String[] help = new String[]{"Help 1", "Help 2", "Help 3"}; when(expr.getHelp()).thenReturn(help); assertArrayEquals(help, test.getHelp()); verify(expr).getHelp(); verifyNoMoreInteractions(expr); } |
FilterExpression implements Expression, Configurable { @Override public boolean isAction() { return expression.isAction(); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void finish(); @Override String[] getUsage(); ... | @Test public void isAction() { when(expr.isAction()).thenReturn(true).thenReturn(false); assertTrue(test.isAction()); assertFalse(test.isAction()); verify(expr, times(2)).isAction(); verifyNoMoreInteractions(expr); } |
FilterExpression implements Expression, Configurable { @Override public boolean isOperator() { return expression.isOperator(); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void finish(); @Override String[] getUsage... | @Test public void isOperator() { when(expr.isAction()).thenReturn(true).thenReturn(false); assertTrue(test.isAction()); assertFalse(test.isAction()); verify(expr, times(2)).isAction(); verifyNoMoreInteractions(expr); } |
FilterExpression implements Expression, Configurable { @Override public int getPrecedence() { return expression.getPrecedence(); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void finish(); @Override String[] getUsa... | @Test public void getPrecedence() { int precedence = 12345; when(expr.getPrecedence()).thenReturn(precedence); assertEquals(precedence, test.getPrecedence()); verify(expr).getPrecedence(); verifyNoMoreInteractions(expr); } |
FilterExpression implements Expression, Configurable { @Override public void addChildren(Deque<Expression> expressions) { expression.addChildren(expressions); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void finis... | @Test public void addChildren() { @SuppressWarnings("unchecked") Deque<Expression> expressions = mock(Deque.class); test.addChildren(expressions); verify(expr).addChildren(expressions); verifyNoMoreInteractions(expr); } |
FilterExpression implements Expression, Configurable { @Override public void addArguments(Deque<String> args) { expression.addArguments(args); } protected FilterExpression(Expression expression); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void finish(); @Override S... | @Test public void addArguments() { @SuppressWarnings("unchecked") Deque<String> args = mock(Deque.class); test.addArguments(args); verify(expr).addArguments(args); verifyNoMoreInteractions(expr); } |
Not extends BaseExpression { @Override public void addChildren(Deque<Expression> expressions) { addChildren(expressions, 1); } Not(); @Override Result apply(PathData item); @Override boolean isOperator(); @Override int getPrecedence(); @Override void addChildren(Deque<Expression> expressions); static void registerExpre... | @Test public void testInit() throws IOException { Not not = new Not(); Expression child = mock(Expression.class); Deque<Expression> children = new LinkedList<Expression>(); children.add(child); not.addChildren(children); FindOptions options = mock(FindOptions.class); not.initialise(options); verify(child).initialise(op... |
Depth extends BaseExpression { @Override public Result apply(PathData item) { return Result.PASS; } Depth(); @Override Result apply(PathData item); @Override void initialise(FindOptions options); static void registerExpression(ExpressionFactory factory); } | @Test public void apply() throws IOException{ Depth depth = new Depth(); depth.initialise(new FindOptions()); assertEquals(Result.PASS, depth.apply(new PathData("anything", new Configuration()))); } |
Or extends BaseExpression { @Override public void addChildren(Deque<Expression> expressions) { addChildren(expressions, 2); } Or(); @Override Result apply(PathData item); @Override boolean isOperator(); @Override int getPrecedence(); @Override void addChildren(Deque<Expression> expressions); static void registerExpress... | @Test public void testInit() throws IOException { Or or = new Or(); Expression first = mock(Expression.class); Expression second = mock(Expression.class); Deque<Expression> children = new LinkedList<Expression>(); children.add(second); children.add(first); or.addChildren(children); FindOptions options = mock(FindOption... |
Atime extends NumberExpression { @Override public Result apply(PathData item) throws IOException { return applyNumber(getOptions().getStartTime() - getFileStatus(item).getAccessTime()); } Atime(); Atime(long units); @Override Result apply(PathData item); static void registerExpression(ExpressionFactory factory); } | @Test public void testExact() throws IOException { Atime atime = new Atime(); addArgument(atime, "5"); FindOptions options = new FindOptions(); options.setStartTime(NOW); atime.initialise(options); assertEquals(Result.FAIL, atime.apply(fourDays)); assertEquals(Result.FAIL, atime.apply(fiveDaysMinus)); assertEquals(Resu... |
Exec extends BaseExpression { @Override public void addArguments(Deque<String> args) { while(!args.isEmpty()) { String arg = args.pop(); if("+".equals(arg) && !getArguments().isEmpty() && "{}".equals(getArguments().get(getArguments().size() - 1))) { setBatch(true); break; } else if(";".equals(arg)) { break; } else { ad... | @Test public void addArguments() throws IOException { Exec exec = new Exec(); exec.addArguments(getArgs("one two three ; four")); assertEquals("Exec(one,two,three;)", exec.toString()); assertFalse(exec.isBatch()); } |
Empty extends BaseExpression { @Override public Result apply(PathData item) throws IOException { FileStatus fileStatus = getFileStatus(item); if(fileStatus.isDirectory()) { if(getFileSystem(item).listStatus(getPath(item)).length == 0) { return Result.PASS; } return Result.FAIL; } if(fileStatus.getLen() == 0l) { return ... | @Test public void applyEmptyFile() throws IOException { FileStatus fileStatus = mock(FileStatus.class); when(fileStatus.isDirectory()).thenReturn(false); when(fileStatus.getLen()).thenReturn(0l); fs.setFileStatus("emptyFile", fileStatus); PathData item = new PathData("emptyFile", fs.getConf()); Empty empty = new Empty(... |
Print extends BaseExpression { public Print(boolean appendNull) { super(); setUsage(USAGE); setHelp(HELP); setAppendNull(appendNull); } Print(boolean appendNull); Print(); @Override Result apply(PathData item); @Override boolean isAction(); static void registerExpression(ExpressionFactory factory); } | @Test public void testPrint() throws IOException{ Print print = new Print(); PrintStream out = mock(PrintStream.class); FindOptions options = new FindOptions(); options.setOut(out); print.initialise(options); String filename = "/one/two/test"; PathData item = new PathData(filename, conf); assertEquals(Result.PASS, prin... |
Prune extends BaseExpression { @Override public Result apply(PathData item) throws IOException { if(getOptions().isDepth()) { return Result.PASS; } return Result.STOP; } Prune(); @Override Result apply(PathData item); static void registerExpression(ExpressionFactory factory); } | @Test public void apply() throws IOException { Prune prune = new Prune(); PathData item = mock(PathData.class); Result result = prune.apply(item); assertTrue(result.isPass()); assertFalse(result.isDescend()); }
@Test public void applyDepth() throws IOException { Prune prune = new Prune(); FindOptions options = new Find... |
Nogroup extends BaseExpression { @Override public Result apply(PathData item) throws IOException { String group = getFileStatus(item).getGroup(); if((group == null) || (group.equals(""))) { return Result.PASS; } return Result.FAIL; } Nogroup(); @Override Result apply(PathData item); static void registerExpression(Expre... | @Test public void applyPass() throws IOException{ when(fileStatus.getGroup()).thenReturn("user"); assertEquals(Result.FAIL, nogroup.apply(item)); }
@Test public void applyFail() throws IOException { when(fileStatus.getGroup()).thenReturn("notuser"); assertEquals(Result.FAIL, nogroup.apply(item)); }
@Test public void ap... |
Nouser extends BaseExpression { @Override public Result apply(PathData item) throws IOException { String user = getFileStatus(item).getOwner(); if((user == null) || (user.equals(""))) { return Result.PASS; } return Result.FAIL; } Nouser(); @Override Result apply(PathData item); static void registerExpression(Expression... | @Test public void applyPass() throws IOException{ when(fileStatus.getOwner()).thenReturn("user"); assertEquals(Result.FAIL, nouser.apply(item)); }
@Test public void applyFail() throws IOException { when(fileStatus.getOwner()).thenReturn("notuser"); assertEquals(Result.FAIL, nouser.apply(item)); }
@Test public void appl... |
Blocksize extends NumberExpression { @Override public Result apply(PathData item) throws IOException { return applyNumber(getFileStatus(item).getBlockSize()); } Blocksize(); @Override Result apply(PathData item); static void registerExpression(ExpressionFactory factory); } | @Test public void applyEquals() throws IOException { Blocksize blocksize = new Blocksize(); addArgument(blocksize, "3"); blocksize.initialise(new FindOptions()); assertEquals(Result.FAIL, blocksize.apply(one)); assertEquals(Result.FAIL, blocksize.apply(two)); assertEquals(Result.PASS, blocksize.apply(three)); assertEqu... |
Result { public Result combine(Result other) { return new Result(this.isPass() && other.isPass(), this.isDescend() && other.isDescend()); } private Result(boolean success, boolean recurse); boolean isDescend(); boolean isPass(); Result combine(Result other); Result negate(); String toString(); @Override int hashCode()... | @Test public void equalsPass() { Result one = Result.PASS; Result two = Result.PASS.combine(Result.PASS); assertEquals(one, two); }
@Test public void equalsFail() { Result one = Result.FAIL; Result two = Result.FAIL.combine(Result.FAIL); assertEquals(one, two); }
@Test public void equalsStop() { Result one = Result.STO... |
Result { @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Result other = (Result) obj; if (descend != other.descend) return false; if (success != other.success) return false; return true; } private Result(boolean ... | @Test public void notEquals() { assertFalse(Result.PASS.equals(Result.FAIL)); assertFalse(Result.PASS.equals(Result.STOP)); assertFalse(Result.FAIL.equals(Result.PASS)); assertFalse(Result.FAIL.equals(Result.STOP)); assertFalse(Result.STOP.equals(Result.PASS)); assertFalse(Result.STOP.equals(Result.FAIL)); } |
Newer extends BaseExpression { @Override public Result apply(PathData item) throws IOException { if(getFileStatus(item).getModificationTime() > filetime) { return Result.PASS; } return Result.FAIL; } Newer(); @Override void initialise(FindOptions options); @Override Result apply(PathData item); @Override void addArgume... | @Test public void applyPass() throws IOException{ FileStatus fileStatus = mock(FileStatus.class); when(fileStatus.getModificationTime()).thenReturn(NOW - (4l*86400000)); fs.setFileStatus("newer.file", fileStatus); PathData item = new PathData("/directory/path/newer.file", fs.getConf()); assertEquals(Result.PASS, newer.... |
Group extends BaseExpression { @Override public Result apply(PathData item) throws IOException { String group = getFileStatus(item).getGroup(); if(requiredGroup.equals(group)) { return Result.PASS; } return Result.FAIL; } Group(); @Override void addArguments(Deque<String> args); @Override void initialise(FindOptions op... | @Test public void applyPass() throws IOException{ when(fileStatus.getGroup()).thenReturn("group"); assertEquals(Result.PASS, group.apply(item)); }
@Test public void applyFail() throws IOException { when(fileStatus.getGroup()).thenReturn("notgroup"); assertEquals(Result.FAIL, group.apply(item)); }
@Test public void appl... |
Mtime extends NumberExpression { @Override public Result apply(PathData item) throws IOException { return applyNumber(getOptions().getStartTime() - getFileStatus(item).getModificationTime()); } Mtime(); Mtime(long units); @Override Result apply(PathData item); static void registerExpression(ExpressionFactory factory);... | @Test public void testExact() throws IOException { Mtime mtime = new Mtime(); addArgument(mtime, "5"); FindOptions options = new FindOptions(); options.setStartTime(NOW); mtime.initialise(options); assertEquals(Result.FAIL, mtime.apply(fourDays)); assertEquals(Result.FAIL, mtime.apply(fiveDaysMinus)); assertEquals(Resu... |
Type extends BaseExpression { @Override public void initialise(FindOptions option) throws IOException { String arg = getArgument(1); if(FILE_TYPES.containsKey(arg)) { this.fileType = FILE_TYPES.get(arg); } else { throw new IOException("Invalid file type: " + arg); } } Type(); @Override void addArguments(Deque<String> a... | @Test public void testInvalidType() throws IOException { Type type = new Type(); addArgument(type, "a"); try { type.initialise(new FindOptions()); fail("Invalid file type not caught"); } catch (IOException e) {} } |
Name extends BaseExpression { @Override public Result apply(PathData item) { String name = getPath(item).getName(); if(!caseSensitive) { name = name.toLowerCase(); } if(globPattern.matches(name)) { return Result.PASS; } else { return Result.FAIL; } } Name(); Name(boolean caseSensitive); @Override void addArguments(Deq... | @Test public void applyPass() throws IOException{ PathData item = new PathData("/directory/path/name", conf); assertEquals(Result.PASS, name.apply(item)); }
@Test public void applyFail() throws IOException{ PathData item = new PathData("/directory/path/notname", conf); assertEquals(Result.FAIL, name.apply(item)); }
@Te... |
Replicas extends NumberExpression { @Override public Result apply(PathData item) throws IOException { return applyNumber(getFileStatus(item).getReplication()); } Replicas(); @Override Result apply(PathData item); static void registerExpression(ExpressionFactory factory); } | @Test public void applyEquals() throws IOException { Replicas rep = new Replicas(); addArgument(rep, "3"); rep.initialise(new FindOptions()); assertEquals(Result.FAIL, rep.apply(one)); assertEquals(Result.FAIL, rep.apply(two)); assertEquals(Result.PASS, rep.apply(three)); assertEquals(Result.FAIL, rep.apply(four)); ass... |
ClassExpression extends FilterExpression { @Override public void addArguments(Deque<String> args) { String classname = args.pop(); expression = ExpressionFactory.getExpressionFactory().createExpression(classname, getConf()); super.addArguments(args); } ClassExpression(); static void registerExpression(ExpressionFactory... | @Test public void addArguments() throws IOException { test.addArguments(getArgs(TestExpression.class.getName() + " arg1 arg2 arg3")); verify(expr).addArguments(getArgs("arg1 arg2 arg3")); }
@Test public void addChildren() throws IOException { @SuppressWarnings("unchecked") LinkedList<Expression> children = mock(LinkedL... |
ClassExpression extends FilterExpression { @Override public boolean isOperator() { if(expression == null) { return false; } return expression.isOperator(); } ClassExpression(); static void registerExpression(ExpressionFactory factory); @Override void addArguments(Deque<String> args); @Override String[] getUsage(); @Ove... | @Test public void isOperator() throws IOException { when(expr.isOperator()).thenReturn(true).thenReturn(false); test.addArguments(getArgs(TestExpression.class.getName())); assertTrue(test.isOperator()); assertFalse(test.isOperator()); verify(expr).addArguments(new LinkedList<String>()); verify(expr, times(2)).isOperato... |
JGitAPIExceptions { public static RuntimeException exceptionWithFriendlyMessageFor(Exception e) { Throwable cause = getRootCause(e); String message = cause.getMessage(); if (message == null) { message = cause.getClass().getSimpleName(); } if (cause instanceof JSchException) { message = "SSH: " + message; } return new R... | @Test public void testExceptionWithFriendlyMessageFor() throws Exception { RuntimeException re = exceptionWithFriendlyMessageFor(new NullPointerException()); assertThat(re.getMessage(), equalTo("NullPointerException")); } |
FilePathMatcher implements Predicate<FilePath> { public int[] match(CharSequence filePath) { Matcher matcher = pattern.matcher(filePath); if (matcher.find()) { for (int i = 0; i < matchingLetters.length; ++i) { matchingLetters[i] = matcher.start(i + 1); } return matchingLetters; } else { return null; } } FilePathMatche... | @Test public void shouldMatchEndOfCandidateString() { assertThat(match("xml", "pom.xml"), is(true)); }
@Test public void shouldNotMatchDifferingEndOfCandidateString() { assertThat(match("xml", "pom.xmo"), is(false)); }
@Test public void shouldMatch() { assertThat(match("attrib", "Documentation/.gitattributes"), is(true... |
RDTTag extends RepoDomainType<TagSummary> { public List<TagSummary> getAll() { final RevWalk revWalk = new RevWalk(repository); List<TagSummary> tagSummaries = newArrayList(transform(repository.getTags().values(), new TagSummaryFactory(revWalk))); sort(tagSummaries, SORT_BY_TIME_AND_NAME); return tagSummaries; } @Injec... | @Test public void shouldHandleTheDatelessAnnotatedTagsThatGitUsedToHave() throws Exception { Repository repository = helper().unpackRepo("git-repo-has-dateless-tag.depth2.zip"); RDTTag rdtTag = new RDTTag(repository); List<TagSummary> listOfTagsInRepo = rdtTag.getAll(); assertThat(listOfTagsInRepo.size(), is(1)); TagSu... |
GitHubWebLaunchActivity extends WebLaunchActivity { Intent cloneLauncherForWebBrowseIntent(Uri uri) { Matcher matcher = projectPathPattern.matcher(uri.getPath()); matcher.find(); return cloneLauncherIntentFor("git: } } | @Test public void shouldSupplyCloneSourceForRegularGithubProjectPage() { Intent cloneIntent = activity.cloneLauncherForWebBrowseIntent(parse("https: assertThat(sourceUriFrom(cloneIntent), is("git: }
@Test public void shouldSupplyOnlyUserepoOwnerAndNameForCloneUrl() { Intent cloneIntent = activity.cloneLauncherForWebBro... |
EmailCommandHandler { public void create(EmailCreateCommand command) throws Exception { EmailAggregate emailAggregate = getByUUID(command.getUuid()); emailAggregate = emailAggregate.create(command); List<AppEvent> pendingEvents = emailAggregate.getUncommittedChanges(); eventSourcingService.save(emailAggregate); pending... | @Test public void create() throws Exception { String uuid = UUID.randomUUID().toString(); EmailCreateCommand command = new EmailCreateCommand( uuid, new Email("Alexsandro", "apssouza22@gmail.com", EmailState.CREATED) ); commandHandler.create(command); verify(eventPublisher, Mockito.times(1)).publish(Mockito.anyObject()... |
EmailCommandHandler { public void send(EmailSendCommand command) throws Exception { EmailAggregate emailAggregate = getByUUID(command.getUuid()); emailAggregate = emailAggregate.send(command); List<AppEvent> pendingEvents = emailAggregate.getUncommittedChanges(); pendingEvents.forEach(eventPublisher::stream); eventSour... | @Test public void send() throws Exception { String uuid = UUID.randomUUID().toString(); EmailSendCommand command = new EmailSendCommand(uuid, Instant.now()); commandHandler.send(command); verify(eventSourcingService, Mockito.times(1)).save(Mockito.any(Aggregate.class)); verify(eventPublisher, Mockito.times(1)).stream(M... |
EmailCommandHandler { public EmailAggregate getByUUID(String uuid) { return EmailAggregate.from(uuid, eventSourcingService.getRelatedEvents(uuid)); } EmailCommandHandler(
EventSourcingService eventSourcingService,
EventPublisher eventPublisher
); void create(EmailCreateCommand command); void... | @Test public void getByUUID() { String uuid = "123"; Mockito.when(eventSourcingService.getAggregate(Mockito.anyString())) .thenReturn(new EventStream()); EmailAggregate byUUID = commandHandler.getByUUID(uuid); Assert.assertTrue(byUUID.getState().getEmail() == null); } |
EmailAggregate extends AbstractAggregate implements Aggregate { public EmailAggregate create(EmailCreateCommand command) throws Exception { if (state.getState() != null) { throw new Exception("Is not possible to edit a deleted email"); } return applyChange(new EmailCreatedEvent(uuid, command.getEmail())); } EmailAggreg... | @Test public void testCreate() throws Exception { final Email email = new Email("alex", "alex@test.com", EmailState.CREATED); String uuid = UUID.randomUUID().toString(); EmailAggregate result = getAggregateWithStateCreated(email,uuid); assertEquals(email.getEmail(), result.getState().getEmail()); assertEquals(email.get... |
EmailAggregate extends AbstractAggregate implements Aggregate { public EmailAggregate send(EmailSendCommand command) throws Exception { if (state.getState() == EmailState.DELETED) { throw new Exception("Is not possible to edit a deleted email"); } return applyChange(new EmailSentEvent( command.getUuid(), getState().set... | @Test public void testSend() throws Exception { final Email email = new Email("alex", "alex@test.com", EmailState.CREATED); String uuid = UUID.randomUUID().toString(); EmailAggregate aggregateWithStateCreated = getAggregateWithStateCreated(email, uuid); EmailSendCommand command = new EmailSendCommand(uuid, Instant.MIN)... |
EmailAggregate extends AbstractAggregate implements Aggregate { @Override public EmailAggregate markChangesAsCommitted() { return new EmailAggregate(uuid, new CopyOnWriteArrayList(), state); } EmailAggregate(String uuid, List<AppEvent> changes); EmailAggregate(String uuid, List<AppEvent> changes, Email state); EmailAg... | @Test public void testMarkChangesAsCommitted() throws Exception { final Email email = new Email("alex", "alex@test.com", EmailState.CREATED); String uuid = UUID.randomUUID().toString(); EmailAggregate instance = getAggregateWithStateCreated(email,uuid); EmailAggregate result = instance.markChangesAsCommitted(); assertF... |
EmailAggregate extends AbstractAggregate implements Aggregate { public EmailAggregate delete(EmailDeleteCommand command) throws Exception { if (state.getState() == EmailState.DELETED) { throw new Exception("Is not possible to delete a deleted email"); } return applyChange(new EmailDeletedEvent(uuid, getState().setState... | @Test public void testDelete() throws Exception { final Email email = new Email("alex", "alex@test.com", EmailState.CREATED); String uuid = UUID.randomUUID().toString(); EmailAggregate aggregateWithStateCreated = getAggregateWithStateCreated(email, uuid); EmailDeleteCommand command = new EmailDeleteCommand(uuid); Email... |
SnorocketReasoner implements IReasoner, Serializable { @Override public IReasoner classify() { if(!isClassified) { no.classify(); isClassified = true; } else { no.classifyIncremental(); } return this; } SnorocketReasoner(); static SnorocketReasoner load(InputStream in); @Override void prune(); @Override Ontology getCla... | @Test public void testBottom() { IFactory factory = new CoreFactory(); NamedConcept a = new NamedConcept("A"); NamedConcept b = new NamedConcept("B"); ConceptInclusion a1 = new ConceptInclusion(a, NamedConcept.BOTTOM_CONCEPT); ConceptInclusion a2 = new ConceptInclusion(b, NamedConcept.TOP_CONCEPT); Set<Axiom> axioms = ... |
NormalisedOntology implements Serializable { public Set<Inclusion> normalise(final Set<? extends Axiom> inclusions) { Set<Inclusion> newIs = transformAxiom(inclusions); Set<Inclusion> oldIs = new HashSet<Inclusion>(newIs.size()); final Set<Inclusion> done = new HashSet<Inclusion>(newIs.size()); do { final Set<Inclusion... | @Test public void testNormalise() { IFactory factory = new CoreFactory(); NamedRole container = new NamedRole("container"); NamedRole contains = new NamedRole("contains"); NamedFeature mgPerTablet = new NamedFeature("mgPerTablet"); NamedConcept panadol = new NamedConcept("Panadol"); NamedConcept panadol_250mg = new Nam... |
Tables { public static String getSQL(Object[] sqlData, Version currentVersion) { try { for (int c = 0; c < sqlData.length; c += 2) { Version curSqlVersion = (Version) sqlData[c]; String curSql = (String) sqlData[c + 1]; if (currentVersion.isMinimum(curSqlVersion)) return curSql; } } catch (Exception e) { throw new Ille... | @Test public void testGetSQL() { assertEquals(Tables.getSQL(SQL, Version.parse("9.0.0")), SQL[3]); assertNotEquals(Tables.getSQL(SQL, Version.parse("9.0.0")), SQL[1]); assertEquals(Tables.getSQL(SQL, Version.parse("9.4.5")), SQL[1]); }
@Test public void testIllegalStateException() { try { String sql = Tables.getSQL(SQL... |
PGTypeTable implements Table<PGTypeTable.Row> { @Override public String getSQL(Version currentVersion) { return Tables.getSQL(SQL, currentVersion); } private PGTypeTable(); @Override String getSQL(Version currentVersion); @Override Row createRow(Context context, ResultBatch resultBatch, int rowIdx); static final PGTyp... | @Test public void testGetSQLVersionEqual() { assertEquals(INSTANCE.getSQL(Version.parse("9.2.0")), SQL[1]); assertNotEquals(INSTANCE.getSQL(Version.parse("9.1.0")), INSTANCE.getSQL(Version.parse("9.2.0"))); }
@Test public void testGetSQLVersionGreater() { assertEquals(INSTANCE.getSQL(Version.parse("9.4.5")), SQL[1]); }... |
PGTypeTable implements Table<PGTypeTable.Row> { @Override public Row createRow(Context context, ResultBatch resultBatch, int rowIdx) throws IOException { Row row = new Row(); row.load(context, resultBatch, rowIdx); return row; } private PGTypeTable(); @Override String getSQL(Version currentVersion); @Override Row crea... | @Test public void testHashCode() { PGTypeTable.Row pgAttrOne = createRow(12345); PGTypeTable.Row pgAttrOneAgain = createRow(12345); PGTypeTable.Row pgAttrTwo = createRow(54321); assertEquals(pgAttrOne.hashCode(), pgAttrOne.hashCode()); assertEquals(pgAttrOne.hashCode(), pgAttrOneAgain.hashCode()); assertNotEquals(pgAtt... |
SearchHistoryEntity implements SearchHistory { @Override @NonNull public String getPlaceId() { return placeId; } SearchHistoryEntity(@NonNull String placeId, CarmenFeature carmenFeature); @Override @NonNull String getPlaceId(); @Override CarmenFeature getCarmenFeature(); } | @Test public void getPlaceId_doesReturnTheSetPlaceId() throws Exception { CarmenFeature feature = CarmenFeature.builder() .properties(new JsonObject()) .build(); SearchHistoryEntity entity = new SearchHistoryEntity("placeId", feature); assertThat(entity.getPlaceId(), equalTo("placeId")); } |
LineManager extends AnnotationManager<LineLayer, Line, LineOptions, OnLineDragListener, OnLineClickListener, OnLineLongClickListener> { @UiThread public List<Line> create(@NonNull String json) { return create(FeatureCollection.fromJson(json)); } @UiThread LineManager(@NonNull MapView mapView, @NonNull MapboxMap mapbox... | @Test public void testGeometryLine() { lineManager = new LineManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController); List<LatLng>latLngs = new ArrayList<>(); latLngs.add(new LatLng()); latLngs.add(new LatLng(1,1)); LineOptions options = new LineOptions().withLatLngs(latLngs);... |
FillManager extends AnnotationManager<FillLayer, Fill, FillOptions, OnFillDragListener, OnFillClickListener, OnFillLongClickListener> { @Override public void setFilter(@NonNull Expression expression) { layerFilter = expression; layer.setFilter(layerFilter); } @UiThread FillManager(@NonNull MapView mapView, @NonNull Ma... | @Test public void testInitializationOnStyleReload() { fillManager = new FillManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController); verify(style).addSource(geoJsonSource); verify(style).addLayer(fillLayer); assertTrue(fillManager.dataDrivenPropertyUsageMap.size() > 0); for (B... |
LocalizationPlugin { public void setMapLanguage(@Languages String language) { setMapLanguage(new MapLocale(language)); } LocalizationPlugin(@NonNull MapView mapView, @NonNull final MapboxMap mapboxMap, @NonNull Style style); void matchMapLanguageWithDeviceDefault(); void matchMapLanguageWithDeviceDefault(boolean accept... | @Test @Ignore public void setMapLanguage_localePassedInNotValid() throws Exception { when(style.isFullyLoaded()).thenReturn(true); thrown.expect(NullPointerException.class); thrown.expectMessage(containsString("has no matching MapLocale object. You need to create")); LocalizationPlugin localizationPlugin = new Localiza... |
MapLocale { @Nullable public static MapLocale getMapLocale(@NonNull Locale locale) { return getMapLocale(locale, false); } MapLocale(@NonNull String mapLanguage); MapLocale(@NonNull LatLngBounds countryBounds); MapLocale(@NonNull @Languages String mapLanguage, @Nullable LatLngBounds countryBounds); @NonNull String ge... | @Test public void regionalVariantsNoFallbackWhenNotRequested() throws Exception { Locale localeHN = new Locale("es_HN", "Honduras"); MapLocale mapLocale = MapLocale.getMapLocale(localeHN, false); assertNull(mapLocale); } |
FillManager extends AnnotationManager<FillLayer, Fill, FillOptions, OnFillDragListener, OnFillClickListener, OnFillLongClickListener> { @UiThread public List<Fill> create(@NonNull String json) { return create(FeatureCollection.fromJson(json)); } @UiThread FillManager(@NonNull MapView mapView, @NonNull MapboxMap mapbox... | @Test public void testAddFill() { fillManager = new FillManager(mapView, mapboxMap, style, coreElementProvider, null, null, draggableAnnotationController); List<LatLng>innerLatLngs = new ArrayList<>(); innerLatLngs.add(new LatLng()); innerLatLngs.add(new LatLng(1,1)); innerLatLngs.add(new LatLng(-1,-1)); innerLatLngs.a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.