@@ -0,0 +1,1938 @@
+package org.modelmapper.functional;%0D%0A%0D%0Aimport static org.testng.Assert.assertEquals;%0D%0A%0D%0Aimport org.modelmapper.AbstractTest;%0D%0Aimport org.modelmapper.Provider;%0D%0Aimport org.modelmapper.config.Configuration.AccessLevel;%0D%0Aimport org.testng.annotations.Test;%0D%0A%0D%0A/**%0D%0A * Maps to an immutable destination.%0D%0A * %0D%0A * @author Jonathan Halterman%0D%0A */%0D%0A@Test(groups = %22functional%22)%0D%0Apublic class Immutable extends AbstractTest %7B%0D%0A  static class Source %7B%0D%0A    String name;%0D%0A    String address;%0D%0A  %7D%0D%0A%0D%0A  static class Destination1 %7B%0D%0A    private final String name;%0D%0A    private final String address;%0D%0A%0D%0A    Destination1(String name, String address) %7B%0D%0A      this.name = name;%0D%0A      this.address = address;%0D%0A    %7D%0D%0A  %7D%0D%0A%0D%0A  static class Destination2 %7B%0D%0A    private final String name = null;%0D%0A    private final String address = null;%0D%0A  %7D%0D%0A%0D%0A  public void shouldMapToImmutableViaProvider() %7B%0D%0A    modelMapper.createTypeMap(Source.class, Destination1.class).setProvider(%0D%0A        new Provider%3CDestination1%3E() %7B%0D%0A          public Destination1 get(ProvisionRequest%3CDestination1%3E request) %7B%0D%0A            Source s = Source.class.cast(request.getSource());%0D%0A            return new Destination1(s.name, s.address);%0D%0A          %7D%0D%0A        %7D);%0D%0A%0D%0A    Source source = new Source();%0D%0A    source.name = %22Joe%22;%0D%0A    source.address = %22Main Street%22;%0D%0A%0D%0A    Destination1 dest1 = modelMapper.map(source, Destination1.class);%0D%0A    assertEquals(dest1.name, %22Joe%22);%0D%0A    assertEquals(dest1.address, %22Main Street%22);%0D%0A  %7D%0D%0A%0D%0A  public void shouldMapToImmutableViaSecurityOverride() %7B%0D%0A    modelMapper.getConfiguration()%0D%0A        .enableFieldMatching(true)%0D%0A        .setFieldAccessLevel(AccessLevel.PRIVATE);%0D%0A%0D%0A    Source source = new Source();%0D%0A    source.name = %22Joe%22;%0D%0A    source.address = %22Main Street%22;%0D%0A%0D%0A    Destination2 dest2 = modelMapper.map(source, Destination2.class);%0D%0A    assertEquals(dest2.name, %22Joe%22);%0D%0A    assertEquals(dest2.address, %22Main Street%22);%0D%0A  %7D%0D%0A%7D%0D%0A

Test demonstration mapping to immutable objects