/** * 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); }
/** *@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); }
/** * 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); }
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);
/** *@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); }
/** *@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); }
/** *@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); }
private void deletePropagatedClassificationExpectFail(AtlasEntity entity, AtlasClassification classification) { try { deletePropagatedClassification(entity, classification); fail(); } catch (AtlasBaseException ex) { Assert.equals(ex.getAtlasErrorCode(), PROPAGATED_CLASSIFICATION_REMOVAL_NOT_SUPPORTED); } }
private void deletePropagatedClassificationExpectFail(AtlasEntity entity, AtlasClassification classification) { try { deletePropagatedClassification(entity, classification); fail(); } catch (AtlasBaseException ex) { Assert.equals(ex.getAtlasErrorCode(), PROPAGATED_CLASSIFICATION_REMOVAL_NOT_SUPPORTED); } }
@Test public void testCartesianProductOfFields2() { Set<String> recordedFields = new HashSet<>(); CardinalityRecord cr = new CardinalityRecord(recordedFields, CardinalityRecord.DateType.DOCUMENT); Map<String,List<String>> valueMap = new HashMap<>(); List<String> list1 = new ArrayList<>(); list1.add("L1V1"); list1.add("L1V2"); list1.add("L1V3"); list1.add("L1V4"); valueMap.put("FIELD1", list1); List<String> results = cr.assembleValues("FIELD1", valueMap); int expectedSize = list1.size(); Assert.equals(expectedSize, results.size()); }
@Test public void testCartesianProductOfFields1() { Set<String> recordedFields = new HashSet<>(); CardinalityRecord cr = new CardinalityRecord(recordedFields, CardinalityRecord.DateType.DOCUMENT); Map<String,List<String>> valueMap = new HashMap<>(); List<String> results = cr.assembleValues("FIELD1", valueMap); Assert.equals(0, results.size()); }
@Test public void testCartesianProductOfFields3() { Set<String> recordedFields = new HashSet<>(); CardinalityRecord cr = new CardinalityRecord(recordedFields, CardinalityRecord.DateType.DOCUMENT); Map<String,List<String>> valueMap = new HashMap<>(); List<String> list1 = new ArrayList<>(); list1.add("L1V1"); list1.add("L1V2"); list1.add("L1V3"); list1.add("L1V4"); valueMap.put("FIELD1", list1); List<String> list2 = new ArrayList<>(); list2.add("L2V1"); list2.add("L2V2"); list2.add("L2V3"); list2.add("L2V4"); valueMap.put("FIELD2", list2); List<String> results = cr.assembleValues("FIELD1|FIELD2", valueMap); int expectedSize = list1.size() * list2.size(); Assert.equals(expectedSize, results.size()); }
/** * Insert an edge with the same origin after this one. * Assumes that the inserted edge is in the correct * position around the ring. * * @param e the edge to insert (with same origin) */ private void insertAfter(HalfEdge e) { Assert.equals(orig, e.orig()); HalfEdge save = oNext(); sym.setNext(e); e.sym().setNext(save); }
Assert.equals(expectedSize, results.size());
@Test public void testConversion() { final Polygon polygonA = new Polygon(Location.CROSSING_85_280, Location.CROSSING_85_17, Location.TEST_1, Location.TEST_5, Location.CROSSING_85_280); final byte[] wkb = this.converter.convert(polygonA); final Polygon polygonB = this.converter.backwardConvert(wkb); Assert.equals(polygonA, polygonB, "Input/output Polygon must be the same"); } }
/** * this is a simple test that puts 2 features in the objectDatabase then retrieves them. It * checks the correlation is correct. */ @Test public void testBulkGet() { ObjectDatabase odb = mock(ObjectDatabase.class); RevFeature f1 = mock(RevFeature.class); when(f1.getId()).thenReturn(getOID(1)); RevFeature f2 = mock(RevFeature.class); when(f2.getId()).thenReturn(getOID(2)); when(odb.getAll(anyObject(), anyObject(), anyObject())) .thenReturn((Arrays.asList((RevObject) f1, (RevObject) f2)).iterator()); BulkObjectDatabaseFeatureRetriever bulk = new BulkObjectDatabaseFeatureRetriever(odb); ObjectId metadataid = getOID(4); Node n1 = Node.create("name1", getOID(1), metadataid, TYPE.FEATURE, new Envelope()); NodeRef nr1 = new NodeRef(n1, "testcase", metadataid); Node n2 = Node.create("name2", getOID(2), metadataid, TYPE.FEATURE, new Envelope()); NodeRef nr2 = new NodeRef(n2, "testcase", metadataid); Iterator<FeatureInfo> it = bulk.apply(Arrays.asList(nr1, nr2)); List<FeatureInfo> feats = Arrays.asList(it.next(), it.next()); Assert.isTrue(feats.get(0).getFeatureTypeId() == metadataid); Assert.isTrue(feats.get(0).getName() .equals("name1")); Assert.equals(feats.get(0).getFeature().getId(), getOID(1)); Assert.isTrue(feats.get(1).getFeatureTypeId() == metadataid); Assert.isTrue(feats.get(1).getName() .equals( "name2")); Assert.equals(feats.get(1).getFeature().getId(), getOID(2)); }
@Test public void testIdenticalFeatureData() { ObjectDatabase odb = mock(ObjectDatabase.class); RevFeature f1 = mock(RevFeature.class); when(f1.getId()).thenReturn(getOID(1)); when(odb.getAll(anyObject(), anyObject(), anyObject())) .thenReturn((Arrays.asList((RevObject) f1 )).iterator()); BulkObjectDatabaseFeatureRetriever bulk = new BulkObjectDatabaseFeatureRetriever(odb); ObjectId metadataid = getOID(4); Node n1 = Node.create("name1", getOID(1), metadataid, TYPE.FEATURE, new Envelope()); NodeRef nr1 = new NodeRef(n1, "testcase", metadataid); Node n2 = Node.create("name2", getOID(1), metadataid, TYPE.FEATURE, new Envelope()); NodeRef nr2 = new NodeRef(n2, "testcase", metadataid); Iterator<FeatureInfo> it = bulk.apply(Arrays.asList(nr1, nr2)); List<FeatureInfo> feats = Lists.newArrayList(it); Assert.isTrue(feats.size() == 2); Assert.isTrue(feats.get(0).getFeatureTypeId() == metadataid); Assert.isTrue(feats.get(0).getName() .equals("name1")); Assert.equals(feats.get(0).getFeature().getId(), getOID(1)); Assert.isTrue(feats.get(1).getFeatureTypeId() == metadataid); Assert.isTrue(feats.get(1).getName() .equals( "name2")); Assert.equals(feats.get(1).getFeature().getId(), getOID(1)); }