use of il.ac.technion.cs.yp.btw.db.DataObjects.DataStreet in project BTW by TechnionYearlyProject.
the class QueryStreet method arrangeRecievedData.
/*
* @author Sharon Hadar
* @Date 21/01/2018
* construct a street from the result of the data base*/
@Override
public Street arrangeRecievedData(ResultSet resultSet) {
Set<Road> roads = new HashSet();
try {
while (resultSet.next()) {
String nameID = resultSet.getString("nameID");
int cord1x = resultSet.getInt("cord1x");
int cord2x = resultSet.getInt("cord2x");
int cord1y = resultSet.getInt("cord1y");
int cord2y = resultSet.getInt("cord2y");
int length = resultSet.getInt("length");
int secStart = resultSet.getInt("secStart");
int secEnd = resultSet.getInt("secEnd");
long overload = resultSet.getLong("overload");
String myStreet = nameID.split("st")[0];
Point sourceCrossroadId = new PointImpl(cord1x, cord1y);
Point destinationCrossroadId = new PointImpl(cord2x, cord2y);
Road road = new DataRoad(nameID, length, myStreet, sourceCrossroadId, destinationCrossroadId, secStart, secEnd, overload, mapName);
roads.add(road);
}
} catch (SQLException e) {
System.out.println("query has failed");
}
return new DataStreet(streetName, roads, mapName);
}
use of il.ac.technion.cs.yp.btw.db.DataObjects.DataStreet in project BTW by TechnionYearlyProject.
the class TestDataStreet method testGet.
@Test
public void testGet() {
Road r1 = new TestingRoad("r1", null, null);
Road r2 = new TestingRoad("r2", null, null);
Road r3 = new TestingRoad("r3", null, null);
Set<Road> roads = new HashSet<Road>();
roads.add(r1);
roads.add(r2);
Street street = new DataStreet("Alenbi", roads, "try");
Street street2 = new DataStreet("Rotchild", "try");
street.addRoad(r3);
Assert.assertTrue(street2.getAllRoadsInStreet().size() == 0);
Assert.assertTrue(street.getAllRoadsInStreet().size() == 3);
Assert.assertTrue(street.getStreetName().equals("Alenbi"));
String s = street.toString();
String s2 = street2.toString();
Assert.assertTrue(s.contains("Alenbi"));
Assert.assertTrue(s2.contains("Rotchild"));
}
Aggregations