Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Fix TestMeasurementDocuement
Browse files Browse the repository at this point in the history
  • Loading branch information
hb0 committed Jun 30, 2023
1 parent 431c79a commit 569366f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package de.cyface.apitestutils;

import java.io.IOException;
import java.util.UUID;

import de.cyface.apitestutils.fixture.TestFixture;
import io.vertx.core.AsyncResult;
Expand Down Expand Up @@ -133,7 +134,7 @@ public TestEnvironment(final Vertx vertx, final VertxTestContext testContext,
* @return A {@code Future} which is resolves to the id of the created entry if successful.
*/
@SuppressWarnings("unused") // API
public Future<String> insertFixture(final TestFixture fixture) {
public Future<UUID> insertFixture(final TestFixture fixture) {
return fixture.insertTestData(mongoClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ public GeoLocationTestFixture(final List<MeasurementIdentifier> testMeasurementI
}

@Override
public Future<String> insertTestData(MongoClient mongoClient) {
public Future<UUID> insertTestData(MongoClient mongoClient) {

// Insert of test group manager and -user removed after switching to OAuth
final var userId = UUID.randomUUID().toString();
final var userId = UUID.randomUUID();

final Promise<String> promise = Promise.promise();
final Promise<UUID> promise = Promise.promise();
final var testDocuments = testMeasurementIdentifiers.stream().map(
id -> new TestMeasurementDocument(userId, id.getMeasurementIdentifier(), id.getDeviceIdentifier()))
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import io.vertx.core.Future;
import io.vertx.ext.mongo.MongoClient;

import java.util.UUID;

/**
* A provider for test fixture data. Such a provider is required by {@link TestEnvironment} instances.
*
Expand All @@ -37,5 +39,5 @@ public interface TestFixture {
* @param mongoClient The client to access the Mongo database hosting the test data
* @return A {@code Future} which is resolved after inserting the data has completed
*/
Future<String> insertTestData(final MongoClient mongoClient);
Future<UUID> insertTestData(final MongoClient mongoClient);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,21 @@
import io.vertx.core.json.JsonObject;
import io.vertx.ext.mongo.MongoClient;

import java.util.UUID;

/**
* A test document inside the Mongo database which contains an unpacked (deserialized) measurement.
*
* @author Armin Schnabel
* @version 3.0.1
* @version 4.0.0
* @since 1.0.0
*/
public final class TestMeasurementDocument implements MongoTestData {

/**
* The id of the user who uploaded the file.
*/
private final String ownerUserId;
private final UUID ownerUserId;
/**
* The identifier of the measurement encoded in the file.
*/
Expand All @@ -72,15 +74,11 @@ public final class TestMeasurementDocument implements MongoTestData {
* @param measurementIdentifier The identifier of the measurement encoded in the file
* @param deviceIdentifier The worldwide unique identifier of the device the document comes from
*/
public TestMeasurementDocument(final String ownerUserId, final Long measurementIdentifier,
final String deviceIdentifier) {
Validate.notEmpty(ownerUserId);
Validate.notNull(measurementIdentifier);
Validate.notEmpty(deviceIdentifier);

this.ownerUserId = ownerUserId;
this.measurementIdentifier = measurementIdentifier;
this.deviceIdentifier = deviceIdentifier;
public TestMeasurementDocument(final UUID ownerUserId, final Long measurementIdentifier,
final String deviceIdentifier) {
this.ownerUserId = Validate.notNull(ownerUserId);
this.measurementIdentifier = Validate.notNull(measurementIdentifier);
this.deviceIdentifier = Validate.notEmpty(deviceIdentifier);
}

@Override
Expand All @@ -93,8 +91,8 @@ public Future<String> insert(final MongoClient mongoClient) {
.put(METADATA_OS_VERSION_FIELD, "Android 9.0.0")
.put(METADATA_APP_VERSION_FIELD, "1.2.0")
.put(METADATA_LENGTH_FIELD, 1500.2)
.put(USER_ID_FIELD, new JsonObject().put("$oid", ownerUserId)) // new ObjectId() not supported
.put(METADATA_VERSION_FIELD, "2.0.0");
.put(USER_ID_FIELD, ownerUserId.toString())
.put(METADATA_VERSION_FIELD, "3.0.0");

final JsonArray geoLocations = new JsonArray();
final var geometry1 = new JsonObject()
Expand Down

0 comments on commit 569366f

Please sign in to comment.