src_fm_fc_ms_ff
stringlengths
43
86.8k
target
stringlengths
20
276k
Main { static List<StyleError> validate(OptionManager optionManager, CommandLine commandLine) { OpenAPIParser openApiParser = new OpenAPIParser(); ParseOptions parseOptions = new ParseOptions(); parseOptions.setResolve(true); SwaggerParseResult parserResult = openApiParser.readLocation(optionManager.getSource(commandLi...
@Test void validateShouldReturnSixErrorsWithoutOptionFile() throws Exception { OptionManager optionManager = new OptionManager(); Options options = optionManager.getOptions(); CommandLine commandLine = parser.parse(options, new String[]{"-s", "src/test/resources/ping.yaml"}); List<StyleError> errorList = Main.validate(...
NamingValidator { boolean isNamingValid(String name, ValidatorParameters.NamingConvention namingStrategy) { switch (namingStrategy) { case UnderscoreCase: return isUnderscoreCase(name); case CamelCase: return isCamelCase(name); case HyphenCase: return isHyphenCase(name); } return false; } }
@Test void goodUnderscoreCaseShouldReturnTrue() { String goodUnderscoreCase1 = "my_variable"; String goodUnderscoreCase2 = "variable"; String goodUnderscoreCase3 = "my_super_variable"; boolean actual1 = validator.isNamingValid(goodUnderscoreCase1, ValidatorParameters.NamingConvention.UnderscoreCase); boolean actual2 = ...
OpenApiSpecStyleValidator { public List<StyleError> validate(ValidatorParameters parameters) { this.parameters = parameters; validateInfo(); validateOperations(); validateModels(); validateNaming(); return errorAggregator.getErrorList(); } OpenApiSpecStyleValidator(OpenAPI openApi); List<StyleError> validate(ValidatorP...
@Test void validatePingOpenAPI() { OpenAPI openAPI = createPingOpenAPI(); OpenApiSpecStyleValidator validator = new OpenApiSpecStyleValidator(openAPI); ValidatorParameters parameters = new ValidatorParameters(); List<StyleError> errors = validator.validate(parameters); assertTrue(errors.size() == 1); assertEquals("*ERR...
KmlUtil { public static String substituteProperties(String template, KmlPlacemark placemark) { StringBuffer sb = new StringBuffer(); Pattern pattern = Pattern.compile("\\$\\[(.+?)]"); Matcher matcher = pattern.matcher(template); while (matcher.find()) { String property = matcher.group(1); String value = placemark.getPr...
@Test public void testSubstituteProperties() { Map<String, String> properties = new HashMap<>(); properties.put("name", "Bruce Wayne"); properties.put("description", "Batman"); properties.put("Snippet", "I am the night"); KmlPlacemark placemark = new KmlPlacemark(null, null, null, properties); String result1 = KmlUtil....
KmlContainerParser { static KmlContainer createContainer(XmlPullParser parser) throws XmlPullParserException, IOException { return assignPropertiesToContainer(parser); } }
@Test public void testCreateContainerProperty() throws Exception { XmlPullParser xmlPullParser = createParser("amu_basic_folder.kml"); KmlContainer kmlContainer = KmlContainerParser.createContainer(xmlPullParser); assertTrue(kmlContainer.hasProperties()); assertEquals("Basic Folder", kmlContainer.getProperty("name")); ...
KmlLineString extends LineString { public ArrayList<LatLng> getGeometryObject() { List<LatLng> coordinatesList = super.getGeometryObject(); return new ArrayList<>(coordinatesList); } KmlLineString(ArrayList<LatLng> coordinates); KmlLineString(ArrayList<LatLng> coordinates, ArrayList<Double> altitudes); ArrayList<Doubl...
@Test public void testGetKmlGeometryObject() { KmlLineString kmlLineString = createSimpleLineString(); assertNotNull(kmlLineString); assertNotNull(kmlLineString.getGeometryObject()); assertEquals(3, kmlLineString.getGeometryObject().size()); assertEquals(0.0, kmlLineString.getGeometryObject().get(0).latitude, 0); asser...
KmlLineString extends LineString { public ArrayList<Double> getAltitudes() { return mAltitudes; } KmlLineString(ArrayList<LatLng> coordinates); KmlLineString(ArrayList<LatLng> coordinates, ArrayList<Double> altitudes); ArrayList<Double> getAltitudes(); ArrayList<LatLng> getGeometryObject(); }
@Test public void testLineStringAltitudes() { KmlLineString kmlLineString = createSimpleLineString(); assertNotNull(kmlLineString); assertNull(kmlLineString.getAltitudes()); kmlLineString = createSimpleLineStringWithAltitudes(); assertNotNull(kmlLineString); assertNotNull(kmlLineString.getAltitudes()); assertEquals(100...
KmlFeatureParser { static KmlPlacemark createPlacemark(XmlPullParser parser) throws IOException, XmlPullParserException { String styleId = null; KmlStyle inlineStyle = null; HashMap<String, String> properties = new HashMap<String, String>(); Geometry geometry = null; int eventType = parser.getEventType(); while (!(even...
@Test public void testPolygon() throws Exception { XmlPullParser xmlPullParser = createParser("amu_basic_placemark.kml"); KmlPlacemark placemark = KmlFeatureParser.createPlacemark(xmlPullParser); assertNotNull(placemark); assertEquals(placemark.getGeometry().getGeometryType(), "Polygon"); KmlPolygon polygon = ((KmlPoly...
KmlTrack extends KmlLineString { public ArrayList<Long> getTimestamps() { return mTimestamps; } KmlTrack(ArrayList<LatLng> coordinates, ArrayList<Double> altitudes, ArrayList<Long> timestamps, HashMap<String, String> properties); ArrayList<Long> getTimestamps(); HashMap<String, String> getProperties(); }
@Test public void testTimestamps() { KmlTrack kmlTrack = createSimpleTrack(); assertNotNull(kmlTrack); assertNotNull(kmlTrack.getTimestamps()); assertEquals(kmlTrack.getTimestamps().size(), 3); assertEquals(kmlTrack.getTimestamps().get(0), Long.valueOf(1000L)); assertEquals(kmlTrack.getTimestamps().get(1), Long.valueOf...
MultiGeometry implements Geometry { public String getGeometryType() { return geometryType; } MultiGeometry(List<? extends Geometry> geometries); String getGeometryType(); List<Geometry> getGeometryObject(); void setGeometryType(String type); @Override String toString(); }
@Test public void testGetGeometryType() { List<LineString> lineStrings = new ArrayList<>(); lineStrings.add( new LineString( new ArrayList<>(Arrays.asList(new LatLng(0, 0), new LatLng(50, 50))))); lineStrings.add( new LineString( new ArrayList<>(Arrays.asList(new LatLng(56, 65), new LatLng(23, 23))))); mg = new MultiGe...
MultiGeometry implements Geometry { public void setGeometryType(String type) { geometryType = type; } MultiGeometry(List<? extends Geometry> geometries); String getGeometryType(); List<Geometry> getGeometryObject(); void setGeometryType(String type); @Override String toString(); }
@Test public void testSetGeometryType() { List<LineString> lineStrings = new ArrayList<>(); lineStrings.add( new LineString( new ArrayList<>(Arrays.asList(new LatLng(0, 0), new LatLng(50, 50))))); lineStrings.add( new LineString( new ArrayList<>(Arrays.asList(new LatLng(56, 65), new LatLng(23, 23))))); mg = new MultiGe...
MultiGeometry implements Geometry { public List<Geometry> getGeometryObject() { return mGeometries; } MultiGeometry(List<? extends Geometry> geometries); String getGeometryType(); List<Geometry> getGeometryObject(); void setGeometryType(String type); @Override String toString(); }
@Test public void testGetGeometryObject() { List<Point> points = new ArrayList<>(); points.add(new Point(new LatLng(0, 0))); points.add(new Point(new LatLng(5, 5))); points.add(new Point(new LatLng(10, 10))); mg = new MultiGeometry(points); assertEquals(points, mg.getGeometryObject()); points = new ArrayList<>(); mg = ...
LineString implements Geometry<List<LatLng>> { public String getGeometryType() { return GEOMETRY_TYPE; } LineString(List<LatLng> coordinates); String getGeometryType(); List<LatLng> getGeometryObject(); @Override String toString(); }
@Test public void testGetType() { LineString lineString = createSimpleLineString(); assertNotNull(lineString); assertNotNull(lineString.getGeometryType()); assertEquals("LineString", lineString.getGeometryType()); lineString = createLoopedLineString(); assertNotNull(lineString); assertNotNull(lineString.getGeometryType...
LineString implements Geometry<List<LatLng>> { public List<LatLng> getGeometryObject() { return mCoordinates; } LineString(List<LatLng> coordinates); String getGeometryType(); List<LatLng> getGeometryObject(); @Override String toString(); }
@Test public void testGetGeometryObject() { LineString lineString = createSimpleLineString(); assertNotNull(lineString); assertNotNull(lineString.getGeometryObject()); assertEquals(lineString.getGeometryObject().size(), 6); assertEquals(lineString.getGeometryObject().get(0).latitude, 90.0, 0); assertEquals(lineString.g...
GeoJsonPointStyle extends Style implements GeoJsonStyle { @Override public String[] getGeometryType() { return GEOMETRY_TYPE; } GeoJsonPointStyle(); @Override String[] getGeometryType(); float getAlpha(); void setAlpha(float alpha); float getAnchorU(); float getAnchorV(); void setAnchor(float anchorU, float anchorV); b...
@Test public void testGetGeometryType() { assertTrue(Arrays.asList(pointStyle.getGeometryType()).contains("Point")); assertTrue(Arrays.asList(pointStyle.getGeometryType()).contains("MultiPoint")); assertTrue(Arrays.asList(pointStyle.getGeometryType()).contains("GeometryCollection")); assertEquals(3, pointStyle.getGeome...
GeoJsonLayer extends Layer { public Iterable<GeoJsonFeature> getFeatures() { return (Iterable<GeoJsonFeature>) super.getFeatures(); } GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager...
@Test public void testGetFeatures() { int featureCount = 0; for (Feature ignored : mLayer.getFeatures()) { featureCount++; } assertEquals(3, featureCount); }
GeoJsonLayer extends Layer { public void addFeature(GeoJsonFeature feature) { if (feature == null) { throw new IllegalArgumentException("Feature cannot be null"); } super.addFeature(feature); } GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonManager, PolylineManage...
@Test public void testAddFeature() { int featureCount = 0; mLayer.addFeature(new GeoJsonFeature(null, null, null, null)); for (Feature ignored : mLayer.getFeatures()) { featureCount++; } assertEquals(4, featureCount); }
GeoJsonLayer extends Layer { public void removeFeature(GeoJsonFeature feature) { if (feature == null) { throw new IllegalArgumentException("Feature cannot be null"); } super.removeFeature(feature); } GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonManager, Polyline...
@Test public void testRemoveFeature() { int featureCount = 0; for (Feature ignored : mLayer.getFeatures()) { featureCount++; } assertEquals(3, featureCount); }
KmlTrack extends KmlLineString { public HashMap<String, String> getProperties() { return mProperties; } KmlTrack(ArrayList<LatLng> coordinates, ArrayList<Double> altitudes, ArrayList<Long> timestamps, HashMap<String, String> properties); ArrayList<Long> getTimestamps(); HashMap<String, String> getProperties(); }
@Test public void testProperties() { KmlTrack kmlTrack = createSimpleTrack(); assertNotNull(kmlTrack); assertNotNull(kmlTrack.getProperties()); assertEquals(kmlTrack.getProperties().size(), 1); assertEquals(kmlTrack.getProperties().get("key"), "value"); assertNull(kmlTrack.getProperties().get("missingKey")); }
GeoJsonLayer extends Layer { public LatLngBounds getBoundingBox() { return mBoundingBox; } GeoJsonLayer(GoogleMap map, JSONObject geoJsonFile, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverlayManager); GeoJsonLayer(GoogleMap map, int resourc...
@Test public void testGetBoundingBox() { assertEquals( new LatLngBounds(new LatLng(-80, -150), new LatLng(80, 150)), mLayer.getBoundingBox()); }
GeoJsonLineStringStyle extends Style implements GeoJsonStyle { @Override public String[] getGeometryType() { return GEOMETRY_TYPE; } GeoJsonLineStringStyle(); @Override String[] getGeometryType(); int getColor(); void setColor(int color); boolean isClickable(); void setClickable(boolean clickable); boolean isGeodesic()...
@Test public void testGetGeometryType() { assertTrue(Arrays.asList(lineStringStyle.getGeometryType()).contains("LineString")); assertTrue(Arrays.asList(lineStringStyle.getGeometryType()).contains("MultiLineString")); assertTrue(Arrays.asList(lineStringStyle.getGeometryType()).contains("GeometryCollection")); assertEqua...
GeoJsonParser { private void parseGeoJson() { try { GeoJsonFeature feature; String type = mGeoJsonFile.getString("type"); if (type.equals(FEATURE)) { feature = parseFeature(mGeoJsonFile); if (feature != null) { mGeoJsonFeatures.add(feature); } } else if (type.equals(FEATURE_COLLECTION)) { mGeoJsonFeatures.addAll(parseF...
@Test public void testParseGeoJson() throws Exception { JSONObject validGeoJsonObject = new JSONObject( "{ \"type\": \"MultiLineString\",\n" + " \"coordinates\": [\n" + " [ [100.0, 0.0], [101.0, 1.0] ],\n" + " [ [102.0, 2.0], [103.0, 3.0] ]\n" + " ]\n" + " }"); GeoJsonParser parser = new GeoJsonParser(validGeoJsonObjec...
GeoJsonParser { ArrayList<GeoJsonFeature> getFeatures() { return mGeoJsonFeatures; } GeoJsonParser(JSONObject geoJsonFile); static Geometry parseGeometry(JSONObject geoJsonGeometry); }
@Test public void testParseGeometryCollection() throws Exception { GeoJsonParser parser = new GeoJsonParser(validGeometryCollection()); assertEquals(1, parser.getFeatures().size()); for (GeoJsonFeature feature : parser.getFeatures()) { assertEquals("GeometryCollection", feature.getGeometry().getGeometryType()); int siz...
GeoJsonMultiLineString extends MultiGeometry { public String getType() { return getGeometryType(); } GeoJsonMultiLineString(List<GeoJsonLineString> geoJsonLineStrings); String getType(); List<GeoJsonLineString> getLineStrings(); }
@Test public void testGetType() { List<GeoJsonLineString> lineStrings = new ArrayList<>(); lineStrings.add( new GeoJsonLineString( new ArrayList<>(Arrays.asList(new LatLng(0, 0), new LatLng(50, 50))))); lineStrings.add( new GeoJsonLineString( new ArrayList<>(Arrays.asList(new LatLng(80, 10), new LatLng(-54, 12.7))))); ...
GeoJsonMultiLineString extends MultiGeometry { public List<GeoJsonLineString> getLineStrings() { List<Geometry> geometryList = getGeometryObject(); ArrayList<GeoJsonLineString> geoJsonLineStrings = new ArrayList<GeoJsonLineString>(); for (Geometry geometry : geometryList) { GeoJsonLineString lineString = (GeoJsonLineSt...
@Test public void testGetLineStrings() { List<GeoJsonLineString> lineStrings = new ArrayList<>(); lineStrings.add( new GeoJsonLineString( new ArrayList<>(Arrays.asList(new LatLng(0, 0), new LatLng(50, 50))))); lineStrings.add( new GeoJsonLineString( new ArrayList<>(Arrays.asList(new LatLng(80, 10), new LatLng(-54, 12.7...
GeoJsonFeature extends Feature implements Observer { public void setGeometry(Geometry geometry) { super.setGeometry(geometry); setChanged(); notifyObservers(); } GeoJsonFeature(Geometry geometry, String id, HashMap<String, String> properties, LatLngBounds boundingBox); String setProperty(Strin...
@Test public void testGeometry() { GeoJsonFeature feature = new GeoJsonFeature(null, null, null, null); assertNull(feature.getGeometry()); GeoJsonPoint point = new GeoJsonPoint(new LatLng(0, 0)); feature.setGeometry(point); assertEquals(point, feature.getGeometry()); feature.setGeometry(null); assertNull(feature.getGeo...
GeoJsonFeature extends Feature implements Observer { public LatLngBounds getBoundingBox() { return mBoundingBox; } GeoJsonFeature(Geometry geometry, String id, HashMap<String, String> properties, LatLngBounds boundingBox); String setProperty(String property, String propertyValue); String remov...
@Test public void testGetBoundingBox() { GeoJsonFeature feature = new GeoJsonFeature(null, null, null, null); assertNull(feature.getBoundingBox()); LatLngBounds boundingBox = new LatLngBounds(new LatLng(-20, -20), new LatLng(50, 50)); feature = new GeoJsonFeature(null, null, null, boundingBox); assertEquals(boundingBox...
GeoJsonLineString extends LineString { public String getType() { return getGeometryType(); } GeoJsonLineString(List<LatLng> coordinates); GeoJsonLineString(List<LatLng> coordinates, List<Double> altitudes); String getType(); List<LatLng> getCoordinates(); List<Double> getAltitudes(); }
@Test public void testGetType() { List<LatLng> coordinates = new ArrayList<>(); coordinates.add(new LatLng(0, 0)); coordinates.add(new LatLng(50, 50)); coordinates.add(new LatLng(100, 100)); ls = new GeoJsonLineString(coordinates); assertEquals("LineString", ls.getType()); }
KmlMultiGeometry extends MultiGeometry { public ArrayList<Geometry> getGeometryObject() { List<Geometry> geometriesList = super.getGeometryObject(); return new ArrayList<>(geometriesList); } KmlMultiGeometry(ArrayList<Geometry> geometries); ArrayList<Geometry> getGeometryObject(); @Override String toString(); }
@Test public void testGetGeometry() { KmlMultiGeometry kmlMultiGeometry = createMultiGeometry(); Assert.assertNotNull(kmlMultiGeometry); Assert.assertEquals(1, kmlMultiGeometry.getGeometryObject().size()); KmlLineString lineString = ((KmlLineString) kmlMultiGeometry.getGeometryObject().get(0)); Assert.assertNotNull(lin...
GeoJsonLineString extends LineString { public List<LatLng> getCoordinates() { return getGeometryObject(); } GeoJsonLineString(List<LatLng> coordinates); GeoJsonLineString(List<LatLng> coordinates, List<Double> altitudes); String getType(); List<LatLng> getCoordinates(); List<Double> getAltitudes(); }
@Test public void testGetCoordinates() { List<LatLng> coordinates = new ArrayList<>(); coordinates.add(new LatLng(0, 0)); coordinates.add(new LatLng(50, 50)); coordinates.add(new LatLng(100, 100)); ls = new GeoJsonLineString(coordinates); assertEquals(coordinates, ls.getCoordinates()); try { ls = new GeoJsonLineString(...
GeoJsonLineString extends LineString { public List<Double> getAltitudes() { return mAltitudes; } GeoJsonLineString(List<LatLng> coordinates); GeoJsonLineString(List<LatLng> coordinates, List<Double> altitudes); String getType(); List<LatLng> getCoordinates(); List<Double> getAltitudes(); }
@Test public void testGetAltitudes() { List<LatLng> coordinates = new ArrayList<>(); coordinates.add(new LatLng(0, 0)); coordinates.add(new LatLng(50, 50)); coordinates.add(new LatLng(100, 100)); List<Double> altitudes = new ArrayList<>(); altitudes.add(100d); altitudes.add(200d); altitudes.add(300d); ls = new GeoJsonL...
GeoJsonPoint extends Point { public String getType() { return getGeometryType(); } GeoJsonPoint(LatLng coordinates); GeoJsonPoint(LatLng coordinates, Double altitude); String getType(); LatLng getCoordinates(); Double getAltitude(); }
@Test public void testGetType() { GeoJsonPoint p = new GeoJsonPoint(new LatLng(0, 0)); assertEquals("Point", p.getType()); }
GeoJsonPoint extends Point { public LatLng getCoordinates() { return getGeometryObject(); } GeoJsonPoint(LatLng coordinates); GeoJsonPoint(LatLng coordinates, Double altitude); String getType(); LatLng getCoordinates(); Double getAltitude(); }
@Test public void testGetCoordinates() { GeoJsonPoint p = new GeoJsonPoint(new LatLng(0, 0)); assertEquals(new LatLng(0, 0), p.getCoordinates()); try { new GeoJsonPoint(null); fail(); } catch (IllegalArgumentException e) { assertEquals("Coordinates cannot be null", e.getMessage()); } }
GeoJsonPoint extends Point { public Double getAltitude() { return mAltitude; } GeoJsonPoint(LatLng coordinates); GeoJsonPoint(LatLng coordinates, Double altitude); String getType(); LatLng getCoordinates(); Double getAltitude(); }
@Test public void testGetAltitude() { GeoJsonPoint p = new GeoJsonPoint(new LatLng(0, 0), 100d); assertEquals(new Double(100), p.getAltitude()); }
GeoJsonMultiPoint extends MultiGeometry { public String getType() { return getGeometryType(); } GeoJsonMultiPoint(List<GeoJsonPoint> geoJsonPoints); String getType(); List<GeoJsonPoint> getPoints(); }
@Test public void testGetType() { List<GeoJsonPoint> points = new ArrayList<>(); points.add(new GeoJsonPoint(new LatLng(0, 0))); points.add(new GeoJsonPoint(new LatLng(5, 5))); points.add(new GeoJsonPoint(new LatLng(10, 10))); mp = new GeoJsonMultiPoint(points); assertEquals("MultiPoint", mp.getType()); }
GeoJsonMultiPoint extends MultiGeometry { public List<GeoJsonPoint> getPoints() { List<Geometry> geometryList = getGeometryObject(); ArrayList<GeoJsonPoint> geoJsonPoints = new ArrayList<GeoJsonPoint>(); for (Geometry geometry : geometryList) { GeoJsonPoint point = (GeoJsonPoint) geometry; geoJsonPoints.add(point); } r...
@Test public void testGetPoints() { List<GeoJsonPoint> points = new ArrayList<>(); points.add(new GeoJsonPoint(new LatLng(0, 0))); points.add(new GeoJsonPoint(new LatLng(5, 5))); points.add(new GeoJsonPoint(new LatLng(10, 10))); mp = new GeoJsonMultiPoint(points); assertEquals(points, mp.getPoints()); points = new Arra...
GeoJsonPolygon implements DataPolygon { public String getType() { return GEOMETRY_TYPE; } GeoJsonPolygon( List<? extends List<LatLng>> coordinates); String getType(); List<? extends List<LatLng>> getCoordinates(); List<? extends List<LatLng>> getGeometryObject(); String getGeometryType(); ArrayList<LatLng> ...
@Test public void testGetType() { List<List<LatLng>> coordinates = new ArrayList<>(); coordinates.add( new ArrayList<>( Arrays.asList( new LatLng(0, 0), new LatLng(20, 20), new LatLng(60, 60), new LatLng(0, 0)))); p = new GeoJsonPolygon(coordinates); assertEquals("Polygon", p.getType()); }
GeoJsonPolygon implements DataPolygon { public List<? extends List<LatLng>> getCoordinates() { return mCoordinates; } GeoJsonPolygon( List<? extends List<LatLng>> coordinates); String getType(); List<? extends List<LatLng>> getCoordinates(); List<? extends List<LatLng>> getGeometryObject(); String getGeomet...
@Test public void testGetCoordinates() { List<List<LatLng>> coordinates = new ArrayList<>(); coordinates.add( new ArrayList<>( Arrays.asList( new LatLng(0, 0), new LatLng(20, 20), new LatLng(60, 60), new LatLng(0, 0)))); p = new GeoJsonPolygon(coordinates); assertEquals(coordinates, p.getCoordinates()); coordinates.add...
GeoJsonRenderer extends Renderer implements Observer { public void setMap(GoogleMap map) { super.setMap(map); for (Feature feature : super.getFeatures()) { redrawFeatureToMap((GeoJsonFeature) feature, map); } } GeoJsonRenderer(GoogleMap map, HashMap<GeoJsonFeature, Object> features, MarkerManager markerManager, Polygon...
@Test public void testSetMap() throws Exception { mLayer = new GeoJsonLayer(mMap1, createFeatureCollection()); mMap1 = mLayer.getMap(); mRenderer.setMap(mMap1); assertEquals(mMap1, mRenderer.getMap()); mRenderer.setMap(null); assertNull(mRenderer.getMap()); }
KmlPoint extends Point { public Double getAltitude() { return mAltitude; } KmlPoint(LatLng coordinates); KmlPoint(LatLng coordinates, Double altitude); Double getAltitude(); }
@Test public void testPointAltitude() { KmlPoint kmlPoint = createSimplePoint(); assertNotNull(kmlPoint); assertNull(kmlPoint.getAltitude()); kmlPoint = createSimplePointWithAltitudes(); assertNotNull(kmlPoint); assertNotNull(kmlPoint.getAltitude()); assertEquals(100.0, kmlPoint.getAltitude(), 0); }
GeoJsonRenderer extends Renderer implements Observer { public void addFeature(GeoJsonFeature feature) { super.addFeature(feature); if (isLayerOnMap()) { feature.addObserver(this); } } GeoJsonRenderer(GoogleMap map, HashMap<GeoJsonFeature, Object> features, MarkerManager markerManager, PolygonManager polygonManager, Pol...
@Test public void testAddFeature() { mRenderer.addFeature(mGeoJsonFeature); assertTrue(mRenderer.getFeatures().contains(mGeoJsonFeature)); }
GeoJsonRenderer extends Renderer implements Observer { public void removeLayerFromMap() { if (isLayerOnMap()) { for (Feature feature : super.getFeatures()) { removeFromMap(super.getAllFeatures().get(feature)); feature.deleteObserver(this); } setLayerVisibility(false); } } GeoJsonRenderer(GoogleMap map, HashMap<GeoJsonF...
@Test public void testRemoveLayerFromMap() throws Exception { mLayer = new GeoJsonLayer(mMap1, createFeatureCollection()); mRenderer.removeLayerFromMap(); assertEquals(mMap1, mRenderer.getMap()); }
GeoJsonRenderer extends Renderer implements Observer { public void removeFeature(GeoJsonFeature feature) { super.removeFeature(feature); if (super.getFeatures().contains(feature)) { feature.deleteObserver(this); } } GeoJsonRenderer(GoogleMap map, HashMap<GeoJsonFeature, Object> features, MarkerManager markerManager, Po...
@Test public void testRemoveFeature() { mRenderer.addFeature(mGeoJsonFeature); mRenderer.removeFeature(mGeoJsonFeature); assertFalse(mRenderer.getFeatures().contains(mGeoJsonFeature)); }
GeoJsonMultiPolygon extends MultiGeometry { public String getType() { return getGeometryType(); } GeoJsonMultiPolygon(List<GeoJsonPolygon> geoJsonPolygons); String getType(); List<GeoJsonPolygon> getPolygons(); }
@Test public void testGetType() { List<GeoJsonPolygon> polygons = new ArrayList<>(); List<ArrayList<LatLng>> polygon = new ArrayList<>(); polygon.add( new ArrayList<>( Arrays.asList( new LatLng(0, 0), new LatLng(20, 20), new LatLng(60, 60), new LatLng(0, 0)))); polygons.add(new GeoJsonPolygon(polygon)); polygon = new A...
GeoJsonMultiPolygon extends MultiGeometry { public List<GeoJsonPolygon> getPolygons() { List<Geometry> geometryList = getGeometryObject(); ArrayList<GeoJsonPolygon> geoJsonPolygon = new ArrayList<GeoJsonPolygon>(); for (Geometry geometry : geometryList) { GeoJsonPolygon polygon = (GeoJsonPolygon) geometry; geoJsonPolyg...
@Test public void testGetPolygons() { List<GeoJsonPolygon> polygons = new ArrayList<>(); List<ArrayList<LatLng>> polygon = new ArrayList<>(); polygon.add( new ArrayList<>( Arrays.asList( new LatLng(0, 0), new LatLng(20, 20), new LatLng(60, 60), new LatLng(0, 0)))); polygons.add(new GeoJsonPolygon(polygon)); polygon = n...
GeoJsonPolygonStyle extends Style implements GeoJsonStyle { @Override public String[] getGeometryType() { return GEOMETRY_TYPE; } GeoJsonPolygonStyle(); @Override String[] getGeometryType(); int getFillColor(); void setFillColor(int fillColor); boolean isGeodesic(); void setGeodesic(boolean geodesic); int getStrokeColo...
@Test public void testGetGeometryType() { assertTrue(Arrays.asList(polygonStyle.getGeometryType()).contains("Polygon")); assertTrue(Arrays.asList(polygonStyle.getGeometryType()).contains("MultiPolygon")); assertTrue(Arrays.asList(polygonStyle.getGeometryType()).contains("GeometryCollection")); assertEquals(3, polygonSt...
Renderer { public GoogleMap getMap() { return mMap; } Renderer(GoogleMap map, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOverlayManager groundOverl...
@Test public void testGetMap() { assertEquals(mMap1, mRenderer.getMap()); }
Renderer { public Set<Feature> getFeatures() { return mFeatures.keySet(); } Renderer(GoogleMap map, Context context, MarkerManager markerManager, PolygonManager polygonManager, PolylineManager polylineManager, GroundOver...
@Test public void testGetFeatures() { assertEquals(featureSet, mRenderer.getFeatures()); }
Renderer { protected void addFeature(Feature feature) { Object mapObject = FEATURE_NOT_ON_MAP; if (feature instanceof GeoJsonFeature) { setFeatureDefaultStyles((GeoJsonFeature) feature); } if (mLayerOnMap) { if (mFeatures.containsKey(feature)) { removeFromMap(mFeatures.get(feature)); } if (feature.hasGeometry()) { if (...
@Test public void testAddFeature() { Point p = new Point(new LatLng(30, 50)); Feature feature1 = new Feature(p, null, null); mRenderer.addFeature(feature1); assertTrue(mRenderer.getFeatures().contains(feature1)); }
Renderer { protected void removeFeature(Feature feature) { if (mFeatures.containsKey(feature)) { removeFromMap(mFeatures.remove(feature)); } } Renderer(GoogleMap map, Context context, MarkerManager markerManager, PolygonManager polygonManager, ...
@Test public void testRemoveFeature() { Point p = new Point(new LatLng(40, 50)); Feature feature1 = new Feature(p, null, null); mRenderer.addFeature(feature1); mRenderer.removeFeature(feature1); assertFalse(mRenderer.getFeatures().contains(feature1)); }
KmlPolygon implements DataPolygon<ArrayList<ArrayList<LatLng>>> { public String getGeometryType() { return GEOMETRY_TYPE; } KmlPolygon(List<LatLng> outerBoundaryCoordinates, List<List<LatLng>> innerBoundaryCoordinates); String getGeometryType(); List<List<LatLng>> getGeometryObject(); List<LatLng>...
@Test public void testGetType() { KmlPolygon kmlPolygon = createRegularPolygon(); assertNotNull(kmlPolygon); assertNotNull(kmlPolygon.getGeometryType()); assertEquals("Polygon", kmlPolygon.getGeometryType()); }
Point implements Geometry { public String getGeometryType() { return GEOMETRY_TYPE; } Point(LatLng coordinates); String getGeometryType(); LatLng getGeometryObject(); @Override String toString(); }
@Test public void testGetGeometryType() { Point p = new Point(new LatLng(0, 50)); assertEquals("Point", p.getGeometryType()); }
Point implements Geometry { public LatLng getGeometryObject() { return mCoordinates; } Point(LatLng coordinates); String getGeometryType(); LatLng getGeometryObject(); @Override String toString(); }
@Test public void testGetGeometryObject() { Point p = new Point(new LatLng(0, 50)); assertEquals(new LatLng(0, 50), p.getGeometryObject()); try { new Point(null); fail(); } catch (IllegalArgumentException e) { assertEquals("Coordinates cannot be null", e.getMessage()); } }
Feature extends Observable { public String getId() { return mId; } Feature(Geometry featureGeometry, String id, Map<String, String> properties); Iterable<String> getPropertyKeys(); Iterable getProperties(); String getProperty(String property); String getId(); boolean hasProperty(String property); Geo...
@Test public void testGetId() { Feature feature = new Feature(null, "Pirate", null); assertNotNull(feature.getId()); assertEquals("Pirate", feature.getId()); feature = new Feature(null, null, null); assertNull(feature.getId()); }
Gradient { static int interpolateColor(int color1, int color2, float ratio) { int alpha = (int) ((Color.alpha(color2) - Color.alpha(color1)) * ratio + Color.alpha(color1)); float[] hsv1 = new float[3]; Color.RGBToHSV(Color.red(color1), Color.green(color1), Color.blue(color1), hsv1); float[] hsv2 = new float[3]; Color.R...
@Test public void testInterpolateColor() { assertEquals(RED, Gradient.interpolateColor(RED, RED, 0.5f)); assertEquals(BLUE, Gradient.interpolateColor(BLUE, BLUE, 0.5f)); assertEquals(GREEN, Gradient.interpolateColor(GREEN, GREEN, 0.5f)); int result = Gradient.interpolateColor(RED, BLUE, 0); assertEquals(RED, result); r...
Gradient { int[] generateColorMap(double opacity) { HashMap<Integer, ColorInterval> colorIntervals = generateColorIntervals(); int[] colorMap = new int[mColorMapSize]; ColorInterval interval = colorIntervals.get(0); int start = 0; for (int i = 0; i < mColorMapSize; i++) { if (colorIntervals.containsKey(i)) { interval =...
@Test public void testMoreColorsThanColorMap() { int[] colors = {Color.argb(0, 0, 255, 0), GREEN, RED, BLUE}; float[] startPoints = {0f, 0.2f, 0.5f, 1f}; Gradient g = new Gradient(colors, startPoints, 2); int[] colorMap = g.generateColorMap(1.0); assertEquals(GREEN, colorMap[0]); assertEquals(RED, colorMap[1]); }
PointQuadTree { public void clear() { mChildren = null; if (mItems != null) { mItems.clear(); } } PointQuadTree(double minX, double maxX, double minY, double maxY); PointQuadTree(Bounds bounds); private PointQuadTree(double minX, double maxX, double minY, double maxY, int depth); private PointQuadTree(Bounds bounds,...
@Test public void testClear() { mTree.add(new Item(.1, .1)); mTree.add(new Item(.2, .2)); mTree.add(new Item(.3, .3)); mTree.clear(); Assert.assertEquals(0, searchAll().size()); }
PointQuadTree { public Collection<T> search(Bounds searchBounds) { final List<T> results = new ArrayList<T>(); search(searchBounds, results); return results; } PointQuadTree(double minX, double maxX, double minY, double maxY); PointQuadTree(Bounds bounds); private PointQuadTree(double minX, double maxX, double minY, ...
@Test public void testSearch() { System.gc(); for (int i = 0; i < 10000; i++) { mTree.add(new Item(i / 20000.0, i / 20000.0)); } Assert.assertEquals(10000, searchAll().size()); Assert.assertEquals( 1, mTree.search(new Bounds((double) 0, 0.00001, (double) 0, 0.00001)).size()); Assert.assertEquals(0, mTree.search(new Bou...
SphericalUtil { static double computeAngleBetween(LatLng from, LatLng to) { return distanceRadians(toRadians(from.latitude), toRadians(from.longitude), toRadians(to.latitude), toRadians(to.longitude)); } private SphericalUtil(); static double computeHeading(LatLng from, LatLng to); static LatLng computeOffset(LatLng f...
@Test public void testAngles() { assertEquals(SphericalUtil.computeAngleBetween(up, up), 0, 1e-6); assertEquals(SphericalUtil.computeAngleBetween(down, down), 0, 1e-6); assertEquals(SphericalUtil.computeAngleBetween(left, left), 0, 1e-6); assertEquals(SphericalUtil.computeAngleBetween(right, right), 0, 1e-6); assertEqu...
SphericalUtil { public static double computeDistanceBetween(LatLng from, LatLng to) { return computeAngleBetween(from, to) * EARTH_RADIUS; } private SphericalUtil(); static double computeHeading(LatLng from, LatLng to); static LatLng computeOffset(LatLng from, double distance, double heading); static LatLng computeOff...
@Test public void testDistances() { assertEquals(SphericalUtil.computeDistanceBetween(up, down), Math.PI * EARTH_RADIUS, 1e-6); }
SphericalUtil { public static double computeHeading(LatLng from, LatLng to) { double fromLat = toRadians(from.latitude); double fromLng = toRadians(from.longitude); double toLat = toRadians(to.latitude); double toLng = toRadians(to.longitude); double dLng = toLng - fromLng; double heading = atan2( sin(dLng) * cos(toLat...
@Test public void testHeadings() { assertEquals(SphericalUtil.computeHeading(up, down), -180, 1e-6); assertEquals(SphericalUtil.computeHeading(down, up), 0, 1e-6); assertEquals(SphericalUtil.computeHeading(front, up), 0, 1e-6); assertEquals(SphericalUtil.computeHeading(right, up), 0, 1e-6); assertEquals(SphericalUtil.c...
KmlPolygon implements DataPolygon<ArrayList<ArrayList<LatLng>>> { public List<LatLng> getOuterBoundaryCoordinates() { return mOuterBoundaryCoordinates; } KmlPolygon(List<LatLng> outerBoundaryCoordinates, List<List<LatLng>> innerBoundaryCoordinates); String getGeometryType(); List<List<LatLng>> get...
@Test public void testGetOuterBoundaryCoordinates() { KmlPolygon kmlPolygon = createRegularPolygon(); assertNotNull(kmlPolygon); assertNotNull(kmlPolygon.getOuterBoundaryCoordinates()); kmlPolygon = createOuterPolygon(); assertNotNull(kmlPolygon); assertNotNull(kmlPolygon.getOuterBoundaryCoordinates()); }
SphericalUtil { public static LatLng computeOffset(LatLng from, double distance, double heading) { distance /= EARTH_RADIUS; heading = toRadians(heading); double fromLat = toRadians(from.latitude); double fromLng = toRadians(from.longitude); double cosDistance = cos(distance); double sinDistance = sin(distance); double...
@Test public void testComputeOffset() { expectLatLngApproxEquals(front, SphericalUtil.computeOffset(front, 0, 0)); expectLatLngApproxEquals( up, SphericalUtil.computeOffset(front, Math.PI * EARTH_RADIUS / 2, 0)); expectLatLngApproxEquals( down, SphericalUtil.computeOffset(front, Math.PI * EARTH_RADIUS / 2, 180)); expec...
SphericalUtil { public static LatLng computeOffsetOrigin(LatLng to, double distance, double heading) { heading = toRadians(heading); distance /= EARTH_RADIUS; double n1 = cos(distance); double n2 = sin(distance) * cos(heading); double n3 = sin(distance) * sin(heading); double n4 = sin(toRadians(to.latitude)); double n1...
@Test public void testComputeOffsetOrigin() { expectLatLngApproxEquals(front, SphericalUtil.computeOffsetOrigin(front, 0, 0)); expectLatLngApproxEquals( front, SphericalUtil.computeOffsetOrigin( new LatLng(0, 45), Math.PI * EARTH_RADIUS / 4, 90)); expectLatLngApproxEquals( front, SphericalUtil.computeOffsetOrigin( new ...
SphericalUtil { public static LatLng interpolate(LatLng from, LatLng to, double fraction) { double fromLat = toRadians(from.latitude); double fromLng = toRadians(from.longitude); double toLat = toRadians(to.latitude); double toLng = toRadians(to.longitude); double cosFromLat = cos(fromLat); double cosToLat = cos(toLat)...
@Test public void testInterpolate() { expectLatLngApproxEquals(up, SphericalUtil.interpolate(up, up, 1 / 2.0)); expectLatLngApproxEquals(down, SphericalUtil.interpolate(down, down, 1 / 2.0)); expectLatLngApproxEquals(left, SphericalUtil.interpolate(left, left, 1 / 2.0)); expectLatLngApproxEquals(new LatLng(1, 0), Spher...
SphericalUtil { public static double computeLength(List<LatLng> path) { if (path.size() < 2) { return 0; } double length = 0; LatLng prev = path.get(0); double prevLat = toRadians(prev.latitude); double prevLng = toRadians(prev.longitude); for (LatLng point : path) { double lat = toRadians(point.latitude); double lng =...
@Test public void testComputeLength() { List<LatLng> latLngs; assertEquals(SphericalUtil.computeLength(Collections.<LatLng>emptyList()), 0, 1e-6); assertEquals(SphericalUtil.computeLength(Arrays.asList(new LatLng(0, 0))), 0, 1e-6); latLngs = Arrays.asList(new LatLng(0, 0), new LatLng(0.1, 0.1)); assertEquals( Spherical...
SphericalUtil { public static double computeArea(List<LatLng> path) { return abs(computeSignedArea(path)); } private SphericalUtil(); static double computeHeading(LatLng from, LatLng to); static LatLng computeOffset(LatLng from, double distance, double heading); static LatLng computeOffsetOrigin(LatLng to, double dist...
@Test public void testComputeArea() { assertEquals( SphericalUtil.computeArea(Arrays.asList(right, up, front, down, right)), Math.PI * EARTH_RADIUS * EARTH_RADIUS, .4); assertEquals( SphericalUtil.computeArea(Arrays.asList(right, down, front, up, right)), Math.PI * EARTH_RADIUS * EARTH_RADIUS, .4); }
SphericalUtil { public static double computeSignedArea(List<LatLng> path) { return computeSignedArea(path, EARTH_RADIUS); } private SphericalUtil(); static double computeHeading(LatLng from, LatLng to); static LatLng computeOffset(LatLng from, double distance, double heading); static LatLng computeOffsetOrigin(LatLng ...
@Test public void testComputeSignedArea() { List<LatLng> path = Arrays.asList(right, up, front, down, right); List<LatLng> pathReversed = Arrays.asList(right, down, front, up, right); assertEquals( -SphericalUtil.computeSignedArea(path), SphericalUtil.computeSignedArea(pathReversed), 0); }
PolyUtil { public static boolean containsLocation(LatLng point, List<LatLng> polygon, boolean geodesic) { return containsLocation(point.latitude, point.longitude, polygon, geodesic); } private PolyUtil(); static boolean containsLocation(LatLng point, List<LatLng> polygon, boolean geodesic); static boolean containsLoca...
@Test public void testContainsLocation() { containsCase(makeList(), makeList(), makeList(0, 0)); containsCase(makeList(1, 2), makeList(1, 2), makeList(0, 0)); containsCase(makeList(1, 2, 3, 5), makeList(1, 2, 3, 5), makeList(0, 0, 40, 4)); containsCase( makeList(0., 0., 10., 12., 20., 5.), makeList(10., 12., 10, 11, 19...
PolyUtil { public static List<LatLng> simplify(List<LatLng> poly, double tolerance) { final int n = poly.size(); if (n < 1) { throw new IllegalArgumentException("Polyline must have at least 1 point"); } if (tolerance <= 0) { throw new IllegalArgumentException("Tolerance must be greater than zero"); } boolean closedPoly...
@Test public void testSimplify() { final String LINE = "elfjD~a}uNOnFN~Em@fJv@tEMhGDjDe@hG^nF??@lA?n@IvAC`Ay@A{@DwCA{CF_EC{CEi@PBTFDJBJ?V?n@?D@?A@?@?F?F?LAf@?n@@`@@T@~@FpA?fA?p@?r@?vAH`@OR@^ETFJCLD?JA^?J?P?fAC`B@d@?b@A\\@`@Ad@@\\?`@?f@?V?H?DD@DDBBDBD?D?B?B@B@@@B@B@B@D?D?JAF@H@FCLADBDBDCFAN?b@Af@@x@@"; List<LatLng> line...
PolyUtil { public static boolean isClosedPolygon(List<LatLng> poly) { LatLng firstPoint = poly.get(0); LatLng lastPoint = poly.get(poly.size() - 1); return firstPoint.equals(lastPoint); } private PolyUtil(); static boolean containsLocation(LatLng point, List<LatLng> polygon, boolean geodesic); static boolean containsL...
@Test public void testIsClosedPolygon() { ArrayList<LatLng> poly = new ArrayList<>(); poly.add(new LatLng(28.06025, -82.41030)); poly.add(new LatLng(28.06129, -82.40945)); poly.add(new LatLng(28.06206, -82.40917)); poly.add(new LatLng(28.06125, -82.40850)); poly.add(new LatLng(28.06035, -82.40834)); assertFalse(PolyUti...
PolyUtil { public static double distanceToLine(final LatLng p, final LatLng start, final LatLng end) { if (start.equals(end)) { return computeDistanceBetween(end, p); } final double s0lat = toRadians(p.latitude); final double s0lng = toRadians(p.longitude); final double s1lat = toRadians(start.latitude); final double s...
@Test public void testDistanceToLine() { LatLng startLine = new LatLng(28.05359, -82.41632); LatLng endLine = new LatLng(28.05310, -82.41634); LatLng p = new LatLng(28.05342, -82.41594); double distance = PolyUtil.distanceToLine(p, startLine, endLine); assertEquals(37.947946, distance, 1e-6); } @Test public void testDi...
KmlPolygon implements DataPolygon<ArrayList<ArrayList<LatLng>>> { public List<List<LatLng>> getInnerBoundaryCoordinates() { return mInnerBoundaryCoordinates; } KmlPolygon(List<LatLng> outerBoundaryCoordinates, List<List<LatLng>> innerBoundaryCoordinates); String getGeometryType(); List<List<LatLng...
@Test public void testGetInnerBoundaryCoordinates() { KmlPolygon kmlPolygon = createRegularPolygon(); assertNotNull(kmlPolygon); assertNotNull(kmlPolygon.getInnerBoundaryCoordinates()); kmlPolygon = createOuterPolygon(); assertNotNull(kmlPolygon); assertNull(kmlPolygon.getInnerBoundaryCoordinates()); }
PolyUtil { public static List<LatLng> decode(final String encodedPath) { int len = encodedPath.length(); final List<LatLng> path = new ArrayList<LatLng>(); int index = 0; int lat = 0; int lng = 0; while (index < len) { int result = 1; int shift = 0; int b; do { b = encodedPath.charAt(index++) - 63 - 1; result += b << s...
@Test public void testDecodePath() { List<LatLng> latLngs = PolyUtil.decode(TEST_LINE); int expectedLength = 21; assertEquals("Wrong length.", expectedLength, latLngs.size()); LatLng lastPoint = latLngs.get(expectedLength - 1); assertEquals(37.76953, lastPoint.latitude, 1e-6); assertEquals(-122.41488, lastPoint.longitu...
KmlPolygon implements DataPolygon<ArrayList<ArrayList<LatLng>>> { public List<List<LatLng>> getGeometryObject() { List<List<LatLng>> coordinates = new ArrayList<>(); coordinates.add(mOuterBoundaryCoordinates); if (mInnerBoundaryCoordinates != null) { coordinates.addAll(mInnerBoundaryCoordinates); } return coordinates; ...
@Test public void testGetKmlGeometryObject() { KmlPolygon kmlPolygon = createRegularPolygon(); assertNotNull(kmlPolygon); assertNotNull(kmlPolygon.getGeometryObject()); assertEquals(2, kmlPolygon.getGeometryObject().size()); kmlPolygon = createOuterPolygon(); assertNotNull(kmlPolygon); assertNotNull(kmlPolygon.getGeome...
ExternalSystemRecentTaskListModel extends DefaultListModel { @SuppressWarnings("unchecked") public void setFirst(@Nonnull ExternalTaskExecutionInfo task) { insertElementAt(task, 0); for (int i = 1; i < size(); i++) { if (task.equals(getElementAt(i))) { remove(i); break; } } ensureSize(ExternalSystemConstants.RECENT_TAS...
@Test public void testSetFirst() throws Exception { List<ExternalTaskExecutionInfo> tasks = ContainerUtilRt.newArrayList(); for (int i = 0; i <= ExternalSystemConstants.RECENT_TASKS_NUMBER; i++) { new ExternalTaskExecutionInfo(new ExternalSystemTaskExecutionSettings(), "task" + i); } myModel.setTasks(tasks); myModel.se...
ExternalSystemRecentTaskListModel extends DefaultListModel { @SuppressWarnings("unchecked") public void ensureSize(int elementsNumber) { int toAdd = elementsNumber - size(); if (toAdd == 0) { return; } if(toAdd < 0) { removeRange(elementsNumber, size() - 1); } while (--toAdd >= 0) { addElement(new MyEmptyDescriptor());...
@Test public void testEnsureSize() throws Exception { List<ExternalTaskExecutionInfo> tasks = ContainerUtilRt.newArrayList(); myModel.setTasks(tasks); myModel.ensureSize(ExternalSystemConstants.RECENT_TASKS_NUMBER); Assert.assertEquals("task list widening failed", ExternalSystemConstants.RECENT_TASKS_NUMBER, myModel.ge...
VcsLogMultiRepoJoiner { @Nonnull public List<Commit> join(@Nonnull Collection<List<Commit>> logsFromRepos) { if (logsFromRepos.size() == 1) { return logsFromRepos.iterator().next(); } int size = 0; for (List<Commit> repo : logsFromRepos) { size += repo.size(); } List<Commit> result = new ArrayList<>(size); Map<Commit, ...
@Test public void joinTest() { List<? extends TimedVcsCommit> first = log("6|-a2|-a0", "3|-a1|-a0", "1|-a0|-"); List<? extends TimedVcsCommit> second = log("4|-b1|-b0", "2|-b0|-"); List<? extends TimedVcsCommit> third = log("7|-c1|-c0", "5|-c0|-"); List<TimedVcsCommit> expected = log("7|-c1|-c0", "6|-a2|-a0", "5|-c0|-"...
DefaultArrangementEntryMatcherSerializer { @SuppressWarnings("MethodMayBeStatic") @javax.annotation.Nullable public <T extends ArrangementEntryMatcher> Element serialize(@Nonnull T matcher) { if (matcher instanceof StdArrangementEntryMatcher) { return serialize(((StdArrangementEntryMatcher)matcher).getCondition()); } L...
@Test public void conditionsOrder() { ArrangementCompositeMatchCondition condition = new ArrangementCompositeMatchCondition(); ArrangementSettingsToken typeToPreserve = FIELD; Set<ArrangementSettingsToken> modifiersToPreserve = ContainerUtilRt.newHashSet(PUBLIC, STATIC, FINAL); condition.addOperand(new ArrangementAtomM...
RxDownloader { public Single<List<FileContainer>> asList() { this.subject.subscribe(this.itemsObserver); this.size = this.files.size(); this.remains = this.size; Observable<FileContainer> observable = Observable .fromIterable(this.files) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()); if (ORDE...
@Test public void isMaxStrategyworks() throws Exception { rxDownloader = builder .strategy(DownloadStrategy.MAX) .addFile("http: .build(); List<FileContainer> res = rxDownloader.asList().blockingGet(); res.forEach(fileContainer -> { Log.i("RxDownloader", "key" + fileContainer.getFilename() + ",value " + fileContainer.g...
Utils { public static void shouldAllPositive(int... numbers) { for (int num : numbers) { if (num < 1) { throw new IllegalArgumentException("Number should be > 0"); } } } static int toPositiveInt(String input); static void shouldAllPositive(int... numbers); static void shouldAllNonNegative(int... numbers); }
@Test public void shouldAllPositive() throws Exception { Utils.shouldAllPositive(1, 2, 3, 4); } @Test(expected = IllegalArgumentException.class) public void shouldAllPositive2() throws Exception { Utils.shouldAllPositive(1, -2, 3, 4); } @Test(expected = IllegalArgumentException.class) public void shouldAllPositive3() t...
CommandFactory { public Command getCommand(String commandLine) throws InvalidCommandException, InvalidCommandParams { commandLine = commandLine.trim().replaceAll(" {2}", " "); String[] split = commandLine.split(" "); String mainCommand = split[0].toUpperCase(); String[] params = Arrays.copyOfRange(split, 1, split.lengt...
@Test public void getCommand3() throws Exception { Command command = commandFactory.getCommand("C 20 4"); Assert.assertThat(command, CoreMatchers.instanceOf(CreateCommand.class)); } @Test public void getCommand4() throws Exception { Command command = commandFactory.getCommand("L 1 2 1 22"); Assert.assertThat(command, C...
EntityFactory { public Entity getEntity(DrawEntityCommand command) { if (command instanceof DrawLineCommand) { DrawLineCommand cmd = (DrawLineCommand) command; return new Line(cmd.getX1(), cmd.getY1(), cmd.getX2(), cmd.getY2()); } else if (command instanceof DrawRectangleCommand) { DrawRectangleCommand cmd = (DrawRecta...
@Test public void getEntity_DrawLineCommand() throws Exception { DrawLineCommand drawLineCommand = new DrawLineCommand( "1", "2", "1", "4"); assertEquals(entityFactory.getEntity(drawLineCommand), new Line(1, 2, 1, 4)); } @Test public void getEntity_DrawRectangleCommand() throws Exception { DrawRectangleCommand drawLine...
IEXByteConverter { public static short convertBytesToShort(final byte[] bytes) { return (short) ( (0xff & bytes[1]) << 8 | (0xff & bytes[0]) << 0); } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final byte[] bytes); static int convertBytesToUnsignedShort(...
@Test public void shouldSuccessfullyConvertBytesToShort() { final short value = 24; byte[] bytes = IEXByteTestUtil.convert(value); assertThat(IEXByteConverter.convertBytesToShort(bytes)).isEqualTo(value); }
IEXPrice implements Comparable<IEXPrice>, Serializable { @Override public int hashCode() { return Objects.hashCode(number); } IEXPrice(final long number); long getNumber(); BigDecimal toBigDecimal(); @Override int compareTo(final IEXPrice iexPrice); @Override boolean equals(Object o); @Override int hashCode(); @Overrid...
@Test public void twoObjectsShouldBeEqualWithTheSameNumberInside() { final long number = 43215678L; final IEXPrice iexPrice_1 = new IEXPrice(number); final IEXPrice iexPrice_2 = new IEXPrice(number); assertThat(iexPrice_1).isEqualTo(iexPrice_2); assertThat(iexPrice_1.hashCode()).isEqualTo(iexPrice_2.hashCode()); }
IEXPrice implements Comparable<IEXPrice>, Serializable { @Override public int compareTo(final IEXPrice iexPrice) { return compare(this.getNumber(), iexPrice.getNumber()); } IEXPrice(final long number); long getNumber(); BigDecimal toBigDecimal(); @Override int compareTo(final IEXPrice iexPrice); @Override boolean equal...
@Test public void compareShouldReturnOneForBiggerNumber() { final long biggerNumber = 12345678L; final long smallerNumber = 1234567L; final IEXPrice iexPrice_1 = new IEXPrice(biggerNumber); final IEXPrice iexPrice_2 = new IEXPrice(smallerNumber); assertThat(iexPrice_1.compareTo(iexPrice_2)).isEqualTo(1); } @Test public...
IEXTOPSMessageBlock extends IEXSegment { public static IEXSegment createIEXSegment(final byte[] packet) { final List<IEXMessage> iexMessages = new ArrayList<>(); int offset = 40; final IEXMessageHeader iexMessageHeader = IEXMessageHeader.createIEXMessageHeader(Arrays.copyOfRange(packet, 0, offset)); for (int i = 0; i <...
@Test public void shouldSuccessfullyCreateMessageBlockInstance() { final IEXMessageHeaderDataBuilder messageHeaderBuilder = IEXMessageHeaderDataBuilder.messageHeader() .withMessageCount((short) 2); final IEXTradeMessageDataBuilder tradeMessageBuilder = IEXTradeMessageDataBuilder.tradeMessage(); final IEXQuoteUpdateMess...
IEXByteConverter { public static int convertBytesToUnsignedShort(final byte[] bytes) { return convertBytesToShort(bytes) & 0xffff; } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final byte[] bytes); static int convertBytesToUnsignedShort(final byte[] byte...
@Test public void shouldSuccessfullyConvertBytesToUnsignedShort() { final int value = 32817; byte[] bytes = IEXByteTestUtil.convertUnsignedShort(value); assertThat(IEXByteConverter.convertBytesToUnsignedShort(bytes)).isEqualTo(value); }
IEXByteConverter { public static int convertBytesToInt(final byte[] bytes) { return ((0xff & bytes[3]) << 24 | (0xff & bytes[2]) << 16 | (0xff & bytes[1]) << 8 | (0xff & bytes[0]) << 0 ); } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final byte[] bytes);...
@Test public void shouldSuccessfullyConvertBytesToInt() { final int value = 123456; byte[] bytes = IEXByteTestUtil.convert(value); assertThat(IEXByteConverter.convertBytesToInt(bytes)).isEqualTo(value); }
IEXByteConverter { public static long convertBytesToLong(final byte[] bytes) { return (long) (0xff & bytes[7]) << 56 | (long) (0xff & bytes[6]) << 48 | (long) (0xff & bytes[5]) << 40 | (long) (0xff & bytes[4]) << 32 | (long) (0xff & bytes[3]) << 24 | (long) (0xff & bytes[2]) << 16 | (long) (0xff & bytes[1]) << 8 | (lon...
@Test public void shouldSuccessfullyConvertBytesToLong() { final long value = 1234567891L; byte[] bytes = IEXByteTestUtil.convert(value); assertThat(IEXByteConverter.convertBytesToLong(bytes)).isEqualTo(value); }
IEXByteConverter { public static IEXPrice convertBytesToIEXPrice(final byte[] bytes) { return new IEXPrice(convertBytesToLong(bytes)); } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final byte[] bytes); static int convertBytesToUnsignedShort(final byte[] ...
@Test public void shouldSuccessfullyConvertBytesToIEXPrice() { final IEXPrice iexPrice = new IEXPrice(123456789L); byte[] bytes = IEXByteTestUtil.convert(iexPrice.getNumber()); assertThat(IEXByteConverter.convertBytesToIEXPrice(bytes)).isEqualTo(iexPrice); }
IEXByteConverter { public static String convertBytesToString(final byte[] bytes) { return new String(bytes).trim(); } private IEXByteConverter(); static long convertBytesToLong(final byte[] bytes); static int convertBytesToInt(final byte[] bytes); static int convertBytesToUnsignedShort(final byte[] bytes); static shor...
@Test public void shouldSuccessfullyConvertBytesToString() { final String symbol = "AAPL"; byte[] bytes = IEXByteTestUtil.convert(symbol); assertThat(IEXByteConverter.convertBytesToString(bytes)).isEqualTo(symbol); }
IEXSegment { @Override public int hashCode() { return Objects.hash(messageHeader, messages); } protected IEXSegment( final IEXMessageHeader messageHeader, final List<IEXMessage> messages); IEXMessageHeader getMessageHeader(); List<IEXMessage> getMessages(); @Override boolean equals(Object o); @...
@Test public void shouldTwoInstancesWithSameValuesBeEqual() { final IEXMessageHeader iexMessageHeader = defaultMessageHeader(); final List<IEXMessage> iexMessageList = asList(defaultTradeMessage(), defaultTradeMessage()); final IEXSegment iexSegment_1 = new TestIEXSegment(iexMessageHeader, iexMessageList); final IEXSeg...
IEXMessageHeader { @Override public int hashCode() { return Objects.hash(version, messageProtocolID, channelID, sessionID, payloadLength, messageCount, streamOffset, firstMessageSequenceNumber, sendTime); } private IEXMessageHeader( final byte version, final IEXMessageProtocol messageProtocolID...
@Test public void shouldTwoInstancesWithSameValuesBeEqual() { final IEXMessageHeader iexMessageHeader_1 = defaultMessageHeader(); final IEXMessageHeader iexMessageHeader_2 = defaultMessageHeader(); assertThat(iexMessageHeader_1).isEqualTo(iexMessageHeader_2); assertThat(iexMessageHeader_1.hashCode()).isEqualTo(iexMessa...
IEXPrice implements Comparable<IEXPrice>, Serializable { public long getNumber() { return number; } IEXPrice(final long number); long getNumber(); BigDecimal toBigDecimal(); @Override int compareTo(final IEXPrice iexPrice); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
@Test public void shouldSuccessfullyCreateInstanceThroughConstructor() { final long number = 12345678L; final IEXPrice iexPrice = new IEXPrice(number); assertThat(iexPrice.getNumber()).isEqualTo(number); }
IEXPrice implements Comparable<IEXPrice>, Serializable { @Override public String toString() { return toBigDecimal() .toString(); } IEXPrice(final long number); long getNumber(); BigDecimal toBigDecimal(); @Override int compareTo(final IEXPrice iexPrice); @Override boolean equals(Object o); @Override int hashCode(); @Ov...
@Test public void shouldProperlyFormatPrice() { final long number = 1234567; final IEXPrice iexPrice = new IEXPrice(number); assertThat(iexPrice.toString()).isEqualTo("123.4567"); }
BookServiceImpl implements BookService { @Override @Transactional public Book saveBook(@NotNull @Valid final Book book) { LOGGER.debug("Creating {}", book); Book existing = repository.findOne(book.getId()); if (existing != null) { throw new BookAlreadyExistsException( String.format("There already exists a book with id=...
@Test public void shouldSaveNewUser_GivenThereDoesNotExistOneWithTheSameId_ThenTheSavedUserShouldBeReturned() throws Exception { final Book savedBook = stubRepositoryToReturnUserOnSave(); final Book book = UserUtil.createBook(); final Book returnedBook = bookService.saveBook(book); verify(bookRepository, times(1)).save...
BookServiceImpl implements BookService { @Override @Transactional(readOnly = true) public List<Book> getList() { LOGGER.debug("Retrieving the list of all users"); return repository.findAll(); } @Autowired BookServiceImpl(final BookRepository repository); @Override @Transactional Book saveBook(@NotNull @Valid final Boo...
@Test public void shouldListAllUsers_GivenThereExistSome_ThenTheCollectionShouldBeReturned() throws Exception { stubRepositoryToReturnExistingUsers(10); Collection<Book> list = bookService.getList(); assertNotNull(list); assertEquals(10, list.size()); verify(bookRepository, times(1)).findAll(); } @Test public void shou...
BookController { @RequestMapping(value = "/books", method = RequestMethod.POST, consumes = {"application/json"}) public Book saveBook(@RequestBody @Valid final Book book) { LOGGER.debug("Received request to create the {}", book); return bookService.saveBook(book); } @Autowired BookController(final BookService bookServ...
@Test public void shouldCreateUser() throws Exception { final Book savedBook = stubServiceToReturnStoredBook(); final Book book = UserUtil.createBook(); Book returnedBook = bookController.saveBook(book); verify(bookService, times(1)).saveBook(book); assertEquals("Returned book should come from the service", savedBook, ...
BookController { @ApiOperation(value = "Retrieve a list of books.", responseContainer = "List") @RequestMapping(value = "/books", method = RequestMethod.GET, produces = {"application/json"}) public List<Book> listBooks() { LOGGER.debug("Received request to list all books"); return bookService.getList(); } @Autowired B...
@Test public void shouldListAllUsers() throws Exception { stubServiceToReturnExistingUsers(10); Collection<Book> books = bookController.listBooks(); assertNotNull(books); assertEquals(10, books.size()); verify(bookService, times(1)).getList(); }