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


Check that should create a community for an application . @param vertx event bus to use . @param testContext test context to use .
@Test
  public void shouldCreateCommunityWithMembers(final Vertx vertx, final VertxTestContext testContext) {
    StoreServices.storeApp(new App(), vertx, testContext).onSuccess(app -> {
      addUsersToApp(app.appId, 5, vertx, testContext)
          .onSuccess(users -> testContext.assertComplete(App.getOrCreateDefaultCommunityFor(app.appId, vertx))
              .onSuccess(createdCommunity -> testContext.verify(() -> {
                assertThat(createdCommunity.members).isNotEmpty();
                for (final var member : createdCommunity.members) {
                  assertThat(users.remove(member.userId)).isTrue();
                }
                assertThat(users).isEmpty();
                assertThat(createdCommunity.name).contains(app.appId);
                assertThat(createdCommunity.appId).isEqualTo(app.appId);
                testContext.assertComplete(App.getOrCreateDefaultCommunityFor(app.appId, vertx))
                    .onSuccess(getCommunity -> testContext.verify(() -> {
                      assertThat(createdCommunity).isEqualTo(getCommunity);
                      testContext.completeNow();
                    }));
              })));
    });
  }
@ Test public void shouldCreateCommunityWithMembers ( final Vertx vertx , final VertxTestContext testContext ) { StoreServices . storeApp ( new App ( ) , vertx , testContext ) . onSuccess ( app -> { addUsersToApp ( app . appId , 5 , vertx , testContext ) . onSuccess ( users -> testContext . assertComplete ( App . getOrCreateDefaultCommunityFor ( app . appId , vertx ) ) . onSuccess ( createdCommunity -> testContext . verify ( ( ) -> { assertThat ( createdCommunity . members ) . isNotEmpty ( ) ; for ( final var member : createdCommunity . members ) { assertThat ( users . remove ( member . userId ) ) . isTrue ( ) ; } assertThat ( users ) . isEmpty ( ) ; assertThat ( createdCommunity . name ) . contains ( app . appId ) ; assertThat ( createdCommunity . appId ) . isEqualTo ( app . appId ) ; testContext . assertComplete ( App . getOrCreateDefaultCommunityFor ( app . appId , vertx ) ) . onSuccess ( getCommunity -> testContext . verify ( ( ) -> { assertThat ( createdCommunity ) . isEqualTo ( getCommunity ) ; testContext . completeNow ( ) ; } ) ) ; } ) ) ) ; } ) ; }
Check that should create a community for an application.
Check that should create a community for an application .