components/src/test/java/eu/internetofus/common/components/profile_manager/WeNetProfileManagerTestCase.java
/**
   * Should create, retrieve and delete a community.
   *
   * @param vertx       that contains the event bus to use.
   * @param testContext context over the tests.
   */
Should create, retrieve and delete a community.
@param vertx       that contains the event bus to use.
@param testContext context over the tests.
Should create retrieve and delete a community . @param vertx that contains the event bus to use . @param testContext context over the tests .
@Test
  public void shouldCreateRetrieveUpdateAndDeleteCommunity(final Vertx vertx, final VertxTestContext testContext) {
    new CommunityProfileTest().createModelExample(1, vertx, testContext).onSuccess(community1 -> {
      new CommunityProfileTest().createModelExample(2, vertx, testContext).onSuccess(community2 -> {
        final var service = this.createComponentProxy(vertx);
        testContext.assertComplete(service.createCommunity(community1)).onSuccess(created -> {
          final var id = created.id;
          testContext.assertComplete(service.retrieveCommunity(id)).onSuccess(retrieved -> testContext.verify(() -> {
            assertThat(retrieved).isEqualTo(created);
            community2.id = created.id;
            testContext.assertComplete(service.updateCommunity(community2))
                .onSuccess(updated -> testContext.verify(() -> {
                  assertThat(updated._lastUpdateTs).isGreaterThanOrEqualTo(created._lastUpdateTs);
                  community2._creationTs = updated._creationTs;
                  community2._lastUpdateTs = updated._lastUpdateTs;
                  created._lastUpdateTs = updated._lastUpdateTs;
                  assertThat(updated).isEqualTo(community2).isNotEqualTo(created);
                  testContext.assertComplete(service.retrieveCommunity(id))
                      .onSuccess(retrieved2 -> testContext.verify(() -> {
                        assertThat(retrieved2).isNotEqualTo(created).isEqualTo(updated);
                        testContext.assertComplete(service.deleteCommunity(id)).onSuccess(empty -> {
                          testContext.assertFailure(service.retrieveCommunity(id))
                              .onFailure(error -> testContext.verify(() -> {
                                assertThat(error).isExactlyInstanceOf(ServiceException.class);
                                assertThat(((ServiceException) error).failureCode())
                                    .isEqualTo(Status.NOT_FOUND.getStatusCode());
                                testContext.completeNow();
                              }));
                        });
                      }));
                }));
          }));
        });
      });
    });
  }
@ Test public void shouldCreateRetrieveUpdateAndDeleteCommunity ( final Vertx vertx , final VertxTestContext testContext ) { new CommunityProfileTest ( ) . createModelExample ( 1 , vertx , testContext ) . onSuccess ( community1 -> { new CommunityProfileTest ( ) . createModelExample ( 2 , vertx , testContext ) . onSuccess ( community2 -> { final var service = this . createComponentProxy ( vertx ) ; testContext . assertComplete ( service . createCommunity ( community1 ) ) . onSuccess ( created -> { final var id = created . id ; testContext . assertComplete ( service . retrieveCommunity ( id ) ) . onSuccess ( retrieved -> testContext . verify ( ( ) -> { assertThat ( retrieved ) . isEqualTo ( created ) ; community2 . id = created . id ; testContext . assertComplete ( service . updateCommunity ( community2 ) ) . onSuccess ( updated -> testContext . verify ( ( ) -> { assertThat ( updated . _lastUpdateTs ) . isGreaterThanOrEqualTo ( created . _lastUpdateTs ) ; community2 . _creationTs = updated . _creationTs ; community2 . _lastUpdateTs = updated . _lastUpdateTs ; created . _lastUpdateTs = updated . _lastUpdateTs ; assertThat ( updated ) . isEqualTo ( community2 ) . isNotEqualTo ( created ) ; testContext . assertComplete ( service . retrieveCommunity ( id ) ) . onSuccess ( retrieved2 -> testContext . verify ( ( ) -> { assertThat ( retrieved2 ) . isNotEqualTo ( created ) . isEqualTo ( updated ) ; testContext . assertComplete ( service . deleteCommunity ( id ) ) . onSuccess ( empty -> { testContext . assertFailure ( service . retrieveCommunity ( id ) ) . onFailure ( error -> testContext . verify ( ( ) -> { assertThat ( error ) . isExactlyInstanceOf ( ServiceException . class ) ; assertThat ( ( ( ServiceException ) error ) . failureCode ( ) ) . isEqualTo ( Status . NOT_FOUND . getStatusCode ( ) ) ; testContext . completeNow ( ) ; } ) ) ; } ) ; } ) ) ; } ) ) ; } ) ) ; } ) ; } ) ; } ) ; }
Should create, retrieve and delete a community.
Should create retrieve and delete a community .