components/src/test/java/eu/internetofus/common/components/models/WeNetUserProfileTest.java
/**
   * Check merge add material and modify another.
   *
   * @param vertx       event bus to use.
   * @param testContext context to test.
   *
   * @see WeNetUserProfile#merge(WeNetUserProfile, WeNetValidateContext)
   */
Check merge add material and modify another.
@param vertx       event bus to use.
@param testContext context to test.


Check merge add material and modify another . @param vertx event bus to use . @param testContext context to test .
@Test
  public void shouldMergeAddAndModifyMaterials(final Vertx vertx, final VertxTestContext testContext) {
    final var target = this.createModelExample(1);
    target.materials.clear();
    target.materials.add(new MaterialTest().createModelExample(1));
    target.materials.add(new MaterialTest().createModelExample(2));
    target.materials.add(new MaterialTest().createModelExample(3));
    assertIsValid(target, new WeNetValidateContext("codePrefix", vertx), testContext, () -> {
      final var source = new WeNetUserProfile();
      source.materials = new ArrayList<>();
      source.materials.add(new MaterialTest().createModelExample(2));
      source.materials.add(new MaterialTest().createModelExample(4));
      source.materials.add(new MaterialTest().createModelExample(3));
      source.materials.add(new MaterialTest().createModelExample(1));
      source.materials.get(0).quantity = 143;
      source.materials.get(1).quantity = 144;
      source.materials.get(2).quantity = 145;
      source.materials.get(3).quantity = 146;
      assertCanMerge(target, source, new WeNetValidateContext("codePrefix", vertx), testContext, merged -> {
        assertThat(merged).isNotEqualTo(target).isNotEqualTo(source);
        target.materials.add(target.materials.remove(0));
        target.materials.get(0).quantity = 143;
        target.materials.add(1, new MaterialTest().createModelExample(4));
        target.materials.get(1).quantity = 144;
        target.materials.get(2).quantity = 145;
        target.materials.get(3).quantity = 146;
        assertThat(merged).isEqualTo(target);
      });
    });
  }
@ Test public void shouldMergeAddAndModifyMaterials ( final Vertx vertx , final VertxTestContext testContext ) { final var target = this . createModelExample ( 1 ) ; target . materials . clear ( ) ; target . materials . add ( new MaterialTest ( ) . createModelExample ( 1 ) ) ; target . materials . add ( new MaterialTest ( ) . createModelExample ( 2 ) ) ; target . materials . add ( new MaterialTest ( ) . createModelExample ( 3 ) ) ; assertIsValid ( target , new WeNetValidateContext ( "codePrefix" , vertx ) , testContext , ( ) -> { final var source = new WeNetUserProfile ( ) ; source . materials = new ArrayList < > ( ) ; source . materials . add ( new MaterialTest ( ) . createModelExample ( 2 ) ) ; source . materials . add ( new MaterialTest ( ) . createModelExample ( 4 ) ) ; source . materials . add ( new MaterialTest ( ) . createModelExample ( 3 ) ) ; source . materials . add ( new MaterialTest ( ) . createModelExample ( 1 ) ) ; source . materials . get ( 0 ) . quantity = 143 ; source . materials . get ( 1 ) . quantity = 144 ; source . materials . get ( 2 ) . quantity = 145 ; source . materials . get ( 3 ) . quantity = 146 ; assertCanMerge ( target , source , new WeNetValidateContext ( "codePrefix" , vertx ) , testContext , merged -> { assertThat ( merged ) . isNotEqualTo ( target ) . isNotEqualTo ( source ) ; target . materials . add ( target . materials . remove ( 0 ) ) ; target . materials . get ( 0 ) . quantity = 143 ; target . materials . add ( 1 , new MaterialTest ( ) . createModelExample ( 4 ) ) ; target . materials . get ( 1 ) . quantity = 144 ; target . materials . get ( 2 ) . quantity = 145 ; target . materials . get ( 3 ) . quantity = 146 ; assertThat ( merged ) . isEqualTo ( target ) ; } ) ; } ) ; }
Check merge add material and modify another.
Check merge add material and modify another .