/** * Always throws an <code>AssertionFailedException</code>. * *@throws AssertionFailedException thrown always */ public static void shouldNeverReachHere() { shouldNeverReachHere(null); }
/** * Throws an <code>AssertionFailedException</code> if the given objects are * not equal, according to the <code>equals</code> method. * *@param expectedValue the correct value *@param actualValue the value being checked *@throws AssertionFailedException if the two objects are not equal */ public static void equals(Object expectedValue, Object actualValue) { equals(expectedValue, actualValue, null); }
public Interval(double min, double max) { Assert.isTrue(min <= max); this.min = min; this.max = max; }
throw new TopologyException("side location conflict", e.getCoordinate()); if (leftLoc == Location.NONE) { Assert.shouldNeverReachHere("found single null side (at " + e.getCoordinate() + ")"); Assert.isTrue(label.getLocation(geomIndex, Position.LEFT) == Location.NONE, "found single null side"); label.setLocation(geomIndex, Position.RIGHT, currLoc); label.setLocation(geomIndex, Position.LEFT, currLoc);
@Test public void testIteratorHasErrorFirstElement_hasNext() { Exception except = new RuntimeException(); Iterator it = mock(Iterator.class); when(it.hasNext()).thenReturn(Boolean.TRUE); when(it.next()).thenThrow(except); BackgroundingIterator<Integer> bit = new BackgroundingIterator<Integer>(it, 100); try { bit.hasNext(); } catch (Exception e) { Assert.isTrue(e.getCause() == except); return; // done } Assert.shouldNeverReachHere(); }
public Object clone() { try { Coordinate coord = (Coordinate) super.clone(); return coord; // return the clone } catch (CloneNotSupportedException e) { Assert.shouldNeverReachHere( "this shouldn't happen because this class is Cloneable"); return null; } }
/** * Constructs an AbstractSTRtree with the specified maximum number of child * nodes that a node may have * * @param nodeCapacity the maximum number of child nodes in a node */ public AbstractSTRtree(int nodeCapacity) { Assert.isTrue(nodeCapacity > 1, "Node capacity must be greater than 1"); this.nodeCapacity = nodeCapacity; }
@Test public void testIteratorHasErrorFirstElement_next() { Exception except = new RuntimeException(); Iterator it = mock(Iterator.class); when(it.hasNext()).thenReturn(Boolean.TRUE); when(it.next()).thenThrow(except); BackgroundingIterator<Integer> bit = new BackgroundingIterator<Integer>(it, 100); try { Integer i = bit.next(); // should throw } catch (Exception e) { Assert.isTrue(e.getCause() == except); return; // done } Assert.shouldNeverReachHere(); }
/** *@param vertices the vertices of a linear ring, which may or may not be * flattened (i.e. vertices collinear) *@return the coordinates with unnecessary (collinear) vertices * removed */ private Coordinate[] cleanRing(Coordinate[] original) { Assert.equals(original[0], original[original.length - 1]); ArrayList cleanedRing = new ArrayList(); Coordinate previousDistinctCoordinate = null; for (int i = 0; i <= original.length - 2; i++) { Coordinate currentCoordinate = original[i]; Coordinate nextCoordinate = original[i+1]; if (currentCoordinate.equals(nextCoordinate)) { continue; } if (previousDistinctCoordinate != null && isBetween(previousDistinctCoordinate, currentCoordinate, nextCoordinate)) { continue; } cleanedRing.add(currentCoordinate); previousDistinctCoordinate = currentCoordinate; } cleanedRing.add(original[original.length - 1]); Coordinate[] cleanedRingCoordinates = new Coordinate[cleanedRing.size()]; return (Coordinate[]) cleanedRing.toArray(cleanedRingCoordinates); }
/** * Clones this transformation * * @return a copy of this transformation */ public Object clone() { try { return super.clone(); } catch(Exception ex) { Assert.shouldNeverReachHere(); } return null; } }
/** * Throws an <code>AssertionFailedException</code> if the given assertion is * not true. * *@param assertion a condition that is supposed to be true *@throws AssertionFailedException if the condition is false */ public static void isTrue(boolean assertion) { isTrue(assertion, null); }
/** * Throws an <code>AssertionFailedException</code> if the given objects are * not equal, according to the <code>equals</code> method. * *@param expectedValue the correct value *@param actualValue the value being checked *@throws AssertionFailedException if the two objects are not equal */ public static void equals(Object expectedValue, Object actualValue) { equals(expectedValue, actualValue, null); }
private int getClassSortIndex() { if (sortedClasses == null) initSortedClasses(); for (int i = 0; i < sortedClasses.length; i++) { if (sortedClasses[i].isInstance(this)) return i; } Assert.shouldNeverReachHere("Class not supported: " + this.getClass()); return -1; }
/** * Adds either an AbstractNode, or if this is a leaf node, a data object * (wrapped in an ItemBoundable) */ public void addChildBoundable(Boundable childBoundable) { Assert.isTrue(bounds == null); childBoundables.add(childBoundable); } }
Assert.equals(cqlQuery, expectedQuery); emf, em, pu, PersonCassandra.class, 200); expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = 'ram and wwe' AND \"AGE\" = 10 LIMIT 200 ALLOW FILTERING"; Assert.equals(cqlQuery, expectedQuery); emf, em, pu, PersonCassandra.class, 200); expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = 'Like-==' LIMIT 200 ALLOW FILTERING"; Assert.equals(cqlQuery, expectedQuery); emf, em, pu, PersonCassandra.class, 200); expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = '==1' LIMIT 200 ALLOW FILTERING"; Assert.equals(cqlQuery, expectedQuery); emf, em, pu, PersonCassandra.class, 200); expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = 'in= NOT IN >=set >< <>' LIMIT 200 ALLOW FILTERING"; Assert.equals(cqlQuery, expectedQuery); emf, em, pu, PersonCassandra.class, 200); expectedQuery = "SELECT * FROM \"PERSONCASSANDRA\" WHERE \"PERSON_NAME\" = 'in= between. >=set anand >< or <>' LIMIT 200 ALLOW FILTERING"; Assert.equals(cqlQuery, expectedQuery);
public Geometry getBoundary() { checkNotGeometryCollection(this); Assert.shouldNeverReachHere(); return null; }
protected void init(Coordinate p0, Coordinate p1) { this.p0 = p0; this.p1 = p1; dx = p1.x - p0.x; dy = p1.y - p0.y; quadrant = Quadrant.quadrant(dx, dy); Assert.isTrue(! (dx == 0 && dy == 0), "EdgeEnd with identical endpoints found"); }
private void deletePropagatedClassificationExpectFail(AtlasEntity entity, AtlasClassification classification) { try { deletePropagatedClassification(entity, classification); fail(); } catch (AtlasBaseException ex) { Assert.equals(ex.getAtlasErrorCode(), PROPAGATED_CLASSIFICATION_REMOVAL_NOT_SUPPORTED); } }
/** * Writes a {@link Geometry} in GML2 format to a String. * * @param geom * @return String GML2 Encoded Geometry */ public String write(Geometry geom) { StringWriter writer = new StringWriter(); try { write(geom, writer); } catch (IOException ex) { Assert.shouldNeverReachHere(); } return writer.toString(); }
private List createParentBoundablesFromVerticalSlices(List[] verticalSlices, int newLevel) { Assert.isTrue(verticalSlices.length > 0); List parentBoundables = new ArrayList(); for (int i = 0; i < verticalSlices.length; i++) { parentBoundables.addAll( createParentBoundablesFromVerticalSlice(verticalSlices[i], newLevel)); } return parentBoundables; }