components/src/test/java/eu/internetofus/common/components/personal_context_builder/WeNetPersonalContextBuilderSimulatorTest.java
/**
   * Should add and obtain users locations.
   *
   * @param vertx       that contains the event bus to use.
   * @param testContext context over the tests.
   */
Should add and obtain users locations.
@param vertx       that contains the event bus to use.
@param testContext context over the tests.
Should add and obtain users locations . @param vertx that contains the event bus to use . @param testContext context over the tests .
@Test
  public void shouldAddObtainAndDeleteUserLocation(final Vertx vertx, final VertxTestContext testContext) {
    final var expectedLocations = new UsersLocations();
    final var definedUsers = new Users();
    Future<?> future = Future.succeededFuture();
    for (var i = 0; i < 10; i++) {
      final var location = new UserLocationTest().createModelExample(i);
      definedUsers.userids.add(location.userId);
      definedUsers.userids.add(UUID.randomUUID().toString());
      expectedLocations.locations.add(location);
      future = future
          .compose(ignored -> WeNetPersonalContextBuilderSimulator.createProxy(vertx).addUserLocation(location));
    }
    future = future
        .compose(ignored -> WeNetPersonalContextBuilderSimulator.createProxy(vertx).obtainUserlocations(definedUsers));
    testContext.assertComplete(future).onSuccess(locations -> testContext.verify(() -> {
      assertThat(locations).isEqualTo(expectedLocations);
      testContext
          .assertComplete(WeNetPersonalContextBuilderSimulator.createProxy(vertx)
              .deleteLocation(expectedLocations.locations.get(0).userId).compose(
                  ignore -> WeNetPersonalContextBuilderSimulator.createProxy(vertx).obtainUserlocations(definedUsers)))
          .onSuccess(loctions2 -> testContext.verify(() -> {
            assertThat(loctions2).isNotEqualTo(expectedLocations);
            expectedLocations.locations.remove(0);
            assertThat(loctions2).isEqualTo(expectedLocations);
            testContext.completeNow();
          }));
    }));
  }
@ Test public void shouldAddObtainAndDeleteUserLocation ( final Vertx vertx , final VertxTestContext testContext ) { final var expectedLocations = new UsersLocations ( ) ; final var definedUsers = new Users ( ) ; Future < ? > future = Future . succeededFuture ( ) ; for ( var i = 0 ; i < 10 ; i ++ ) { final var location = new UserLocationTest ( ) . createModelExample ( i ) ; definedUsers . userids . add ( location . userId ) ; definedUsers . userids . add ( UUID . randomUUID ( ) . toString ( ) ) ; expectedLocations . locations . add ( location ) ; future = future . compose ( ignored -> WeNetPersonalContextBuilderSimulator . createProxy ( vertx ) . addUserLocation ( location ) ) ; } future = future . compose ( ignored -> WeNetPersonalContextBuilderSimulator . createProxy ( vertx ) . obtainUserlocations ( definedUsers ) ) ; testContext . assertComplete ( future ) . onSuccess ( locations -> testContext . verify ( ( ) -> { assertThat ( locations ) . isEqualTo ( expectedLocations ) ; testContext . assertComplete ( WeNetPersonalContextBuilderSimulator . createProxy ( vertx ) . deleteLocation ( expectedLocations . locations . get ( 0 ) . userId ) . compose ( ignore -> WeNetPersonalContextBuilderSimulator . createProxy ( vertx ) . obtainUserlocations ( definedUsers ) ) ) . onSuccess ( loctions2 -> testContext . verify ( ( ) -> { assertThat ( loctions2 ) . isNotEqualTo ( expectedLocations ) ; expectedLocations . locations . remove ( 0 ) ; assertThat ( loctions2 ) . isEqualTo ( expectedLocations ) ; testContext . completeNow ( ) ; } ) ) ; } ) ) ; }
Should add and obtain users locations.
Should add and obtain users locations .