Skip to content

Commit

Permalink
fix upload of original track after no obfuscated meaasurements
Browse files Browse the repository at this point in the history
  • Loading branch information
matthesrieke committed Jan 26, 2016
1 parent e0751cd commit 3761b9d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion android-obd-simulator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion "23.0.2"

sourceSets {
main {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ObfuscationTest extends InstrumentationTestCase {
Expand Down Expand Up @@ -73,6 +74,32 @@ public void testObfuscation() throws JSONException, TrackAlreadyFinishedExceptio
}
}

@Test
public void testObfuscationException() throws JSONException, TrackAlreadyFinishedException {
start = System.currentTimeMillis();
end = System.currentTimeMillis() + 1000*60;

first = new MeasurementImpl(51.0, 7.0);
first.setTime(start);
last = new MeasurementImpl(51.03, 7.03);
last.setTime(end);

Track t = new TrackImpl();
t.setCar(new CarImpl("id", "man", "mod", Car.FuelType.DIESEL, 1234, 123));

t.setMeasurements(Arrays.asList(new MeasurementImpl[] {first, last}));

Exception exception = null;
try {
TrackUtils.getObfuscatedTrack(t);
}
catch (NoMeasurementsException e) {
exception = e;
}

Assert.assertNotNull(exception);
}

private Track createTrack() throws TrackAlreadyFinishedException {
Track result = new TrackImpl();
result.setCar(new CarImpl("id", "man", "mod", Car.FuelType.DIESEL, 1234, 123));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ private static List<Measurement> getNonObfuscatedMeasurements(Track track) throw
int last = determineLastNonObfuscatedIndex(measurements, track);

if (first == -1 || last == -1) {
LOG.warn("Could not determine first/last non-obfuscated measurements. Returning originals");
return measurements;
LOG.warn("Could not determine first/last non-obfuscated measurements.");
throw new NoMeasurementsException("No obfuscated measurements available.");
}

for (int i = first; i <= last; i++) {
Expand Down

0 comments on commit 3761b9d

Please sign in to comment.