components/src/test/java/eu/internetofus/common/components/service/AppTest.java
/**
   * Check that should get default community of an application.
   *
   * @param vertx       event bus to use.
   * @param testContext test context to use.
   *
   * @see App#getOrCreateDefaultCommunityFor(String, Vertx)
   */
Check that should get default community of an application.
@param vertx       event bus to use.
@param testContext test context to use.


Check that should get default community of an application . @param vertx event bus to use . @param testContext test context to use .
@Test
  public void shouldGetDefaultCommunityForApp(final Vertx vertx, final VertxTestContext testContext) {
    StoreServices.storeCommunityExample(1, vertx, testContext).onSuccess(defaultCommunity -> {
      addUsersToApp(defaultCommunity.appId, 5, vertx, testContext).onSuccess(users -> {
        testContext.assertComplete(App.getOrCreateDefaultCommunityFor(defaultCommunity.appId, vertx))
            .onSuccess(getCommunity -> testContext.verify(() -> {
              assertThat(getCommunity).isNotEqualTo(defaultCommunity);
              assertThat(getCommunity.members).isNotEmpty();
              defaultCommunity.members = new ArrayList<>();
              for (final var member : getCommunity.members) {
                for (var i = 0; i < users.size(); i++) {
                  if (member.userId.equals(users.getString(i))) {
                    users.remove(i);
                    defaultCommunity.members.add(member);
                    break;
                  }
                }
              }
              assertThat(users).isEmpty();
              defaultCommunity._lastUpdateTs = getCommunity._lastUpdateTs;
              assertThat(getCommunity).isEqualTo(defaultCommunity);
              testContext.completeNow();
            }));
      });
    });
  }
@ Test public void shouldGetDefaultCommunityForApp ( final Vertx vertx , final VertxTestContext testContext ) { StoreServices . storeCommunityExample ( 1 , vertx , testContext ) . onSuccess ( defaultCommunity -> { addUsersToApp ( defaultCommunity . appId , 5 , vertx , testContext ) . onSuccess ( users -> { testContext . assertComplete ( App . getOrCreateDefaultCommunityFor ( defaultCommunity . appId , vertx ) ) . onSuccess ( getCommunity -> testContext . verify ( ( ) -> { assertThat ( getCommunity ) . isNotEqualTo ( defaultCommunity ) ; assertThat ( getCommunity . members ) . isNotEmpty ( ) ; defaultCommunity . members = new ArrayList < > ( ) ; for ( final var member : getCommunity . members ) { for ( var i = 0 ; i < users . size ( ) ; i ++ ) { if ( member . userId . equals ( users . getString ( i ) ) ) { users . remove ( i ) ; defaultCommunity . members . add ( member ) ; break ; } } } assertThat ( users ) . isEmpty ( ) ; defaultCommunity . _lastUpdateTs = getCommunity . _lastUpdateTs ; assertThat ( getCommunity ) . isEqualTo ( defaultCommunity ) ; testContext . completeNow ( ) ; } ) ) ; } ) ; } ) ; }
Check that should get default community of an application.
Check that should get default community of an application .