components/src/test/java/eu/internetofus/common/components/profile_diversity_manager/WeNetProfileDiversityManagerTestCase.java
/**
   * Should calculate the diversity of some agents.
   *
   * @param vertx       that contains the event bus to use.
   * @param testContext context over the tests.
   */
Should calculate the diversity of some agents.
@param vertx       that contains the event bus to use.
@param testContext context over the tests.
Should calculate the diversity of some agents . @param vertx that contains the event bus to use . @param testContext context over the tests .
@Test
  public void shouldCalculateDiversity(final Vertx vertx, final VertxTestContext testContext) {
    final var data = new AgentsData();
    data.agents = new ArrayList<>();
    final var agent1 = new AgentData();
    agent1.id = "1";
    agent1.quantitativeAttributes = new HashMap<>();
    agent1.quantitativeAttributes.put("introvert", 1.0);
    agent1.quantitativeAttributes.put("extrovert", 1.0);
    agent1.quantitativeAttributes.put("naturalist", 1.0);
    agent1.qualitativeAttributes = new HashMap<>();
    agent1.qualitativeAttributes.put("gender", "M");
    agent1.qualitativeAttributes.put("civilStatus", "married");
    data.agents.add(agent1);
    final var agent2 = new AgentData();
    agent2.id = "2";
    agent2.quantitativeAttributes = new HashMap<>();
    agent2.quantitativeAttributes.put("introvert", 0.0);
    agent2.quantitativeAttributes.put("extrovert", 0.0);
    agent2.quantitativeAttributes.put("naturalist", 0.0);
    agent2.qualitativeAttributes = new HashMap<>();
    agent2.qualitativeAttributes.put("gender", "F");
    agent2.qualitativeAttributes.put("civilStatus", "single");
    data.agents.add(agent2);
    data.qualitativeAttributes = new HashMap<>();
    data.qualitativeAttributes.put("gender", new HashSet<>(Arrays.asList("M", "F", "O")));
    data.qualitativeAttributes.put("civilStatus",
        new HashSet<>(Arrays.asList("single", "married", "divorced", "widow")));
    data.quantitativeAttributes = new HashSet<>(Arrays.asList("introvert", "extrovert", "naturalist"));
    this.createComponentProxy(vertx).calculateDiversityOf(data)
        .onComplete(testContext.succeeding(diversity -> testContext.verify(() -> {
          assertThat(diversity.value).isCloseTo(0.5261859507142914d, offset(0.000001));
          testContext.completeNow();
        })));
  }
@ Test public void shouldCalculateDiversity ( final Vertx vertx , final VertxTestContext testContext ) { final var data = new AgentsData ( ) ; data . agents = new ArrayList < > ( ) ; final var agent1 = new AgentData ( ) ; agent1 . id = "1" ; agent1 . quantitativeAttributes = new HashMap < > ( ) ; agent1 . quantitativeAttributes . put ( "introvert" , 1.0 ) ; agent1 . quantitativeAttributes . put ( "extrovert" , 1.0 ) ; agent1 . quantitativeAttributes . put ( "naturalist" , 1.0 ) ; agent1 . qualitativeAttributes = new HashMap < > ( ) ; agent1 . qualitativeAttributes . put ( "gender" , "M" ) ; agent1 . qualitativeAttributes . put ( "civilStatus" , "married" ) ; data . agents . add ( agent1 ) ; final var agent2 = new AgentData ( ) ; agent2 . id = "2" ; agent2 . quantitativeAttributes = new HashMap < > ( ) ; agent2 . quantitativeAttributes . put ( "introvert" , 0.0 ) ; agent2 . quantitativeAttributes . put ( "extrovert" , 0.0 ) ; agent2 . quantitativeAttributes . put ( "naturalist" , 0.0 ) ; agent2 . qualitativeAttributes = new HashMap < > ( ) ; agent2 . qualitativeAttributes . put ( "gender" , "F" ) ; agent2 . qualitativeAttributes . put ( "civilStatus" , "single" ) ; data . agents . add ( agent2 ) ; data . qualitativeAttributes = new HashMap < > ( ) ; data . qualitativeAttributes . put ( "gender" , new HashSet < > ( Arrays . asList ( "M" , "F" , "O" ) ) ) ; data . qualitativeAttributes . put ( "civilStatus" , new HashSet < > ( Arrays . asList ( "single" , "married" , "divorced" , "widow" ) ) ) ; data . quantitativeAttributes = new HashSet < > ( Arrays . asList ( "introvert" , "extrovert" , "naturalist" ) ) ; this . createComponentProxy ( vertx ) . calculateDiversityOf ( data ) . onComplete ( testContext . succeeding ( diversity -> testContext . verify ( ( ) -> { assertThat ( diversity . value ) . isCloseTo ( 0.5261859507142914d , offset ( 0.000001 ) ) ; testContext . completeNow ( ) ; } ) ) ) ; }
Should calculate the diversity of some agents.
Should calculate the diversity of some agents .