components/src/test/java/eu/internetofus/common/components/profile_diversity_manager/WeNetProfileDiversityManagerTestCase.java
/**
   * Should calculate the similarity of some attributes.
   *
   * @param vertx       that contains the event bus to use.
   * @param testContext context over the tests.
   */
Should calculate the similarity of some attributes.
@param vertx       that contains the event bus to use.
@param testContext context over the tests.
Should calculate the similarity of some attributes . @param vertx that contains the event bus to use . @param testContext context over the tests .
@Test
  public void shouldCalculateSimilarity(final Vertx vertx, final VertxTestContext testContext) {
    final var data = new AttributesData();
    data.source = "Do you have a bike?";
    data.attributes = new TreeSet<>();
    data.attributes.add("car");
    data.attributes.add("plane");
    data.attributes.add("vehicle");
    this.createComponentProxy(vertx).calculateSimilarityOf(data)
        .onComplete(testContext.succeeding(similarity -> testContext.verify(() -> {
          final var carSim = new AttributeSimilarity();
          carSim.attribute = "car";
          carSim.similarity = 0.6239031848677311d;
          final var planeSim = new AttributeSimilarity();
          planeSim.attribute = "plane";
          planeSim.similarity = 0.0d;
          final var vehicleSim = new AttributeSimilarity();
          vehicleSim.attribute = "vehicle";
          vehicleSim.similarity = 0.6239031848677311d;
          assertThat(similarity.similarities).hasSize(3).contains(carSim, planeSim, vehicleSim);
          testContext.completeNow();
        })));
  }
@ Test public void shouldCalculateSimilarity ( final Vertx vertx , final VertxTestContext testContext ) { final var data = new AttributesData ( ) ; data . source = "Do you have a bike?" ; data . attributes = new TreeSet < > ( ) ; data . attributes . add ( "car" ) ; data . attributes . add ( "plane" ) ; data . attributes . add ( "vehicle" ) ; this . createComponentProxy ( vertx ) . calculateSimilarityOf ( data ) . onComplete ( testContext . succeeding ( similarity -> testContext . verify ( ( ) -> { final var carSim = new AttributeSimilarity ( ) ; carSim . attribute = "car" ; carSim . similarity = 0.6239031848677311d ; final var planeSim = new AttributeSimilarity ( ) ; planeSim . attribute = "plane" ; planeSim . similarity = 0.0d ; final var vehicleSim = new AttributeSimilarity ( ) ; vehicleSim . attribute = "vehicle" ; vehicleSim . similarity = 0.6239031848677311d ; assertThat ( similarity . similarities ) . hasSize ( 3 ) . contains ( carSim , planeSim , vehicleSim ) ; testContext . completeNow ( ) ; } ) ) ) ; }
Should calculate the similarity of some attributes.
Should calculate the similarity of some attributes .