Java Code Examples for com.fasterxml.jackson.databind.ObjectMapper#enableDefaultTypingAsProperty()

The following examples show how to use com.fasterxml.jackson.databind.ObjectMapper#enableDefaultTypingAsProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProviderApplication.java    From joynr with Apache License 2.0 6 votes vote down vote up
private static void provisionAccessControl(Properties properties, String domain) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        ProviderAnnotations.getInterfaceName(Provider.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{
                                                                                                Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                           provisionedAccessControlEntriesAsJson);
}
 
Example 2
Source File: EchoProviderApplication.java    From joynr with Apache License 2.0 6 votes vote down vote up
private static Properties createAppConfig() throws Exception {
    Properties appConfig = new Properties();

    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        invocationParams.getDomain(),
                                                                                        ProviderAnnotations.getInterfaceName(EchoProviderImpl.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{
                                                                                                Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    appConfig.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                          provisionedAccessControlEntriesAsJson);

    return appConfig;
}
 
Example 3
Source File: IltProviderApplication.java    From joynr with Apache License 2.0 6 votes vote down vote up
private static void provisionAccessControl(Properties properties, String domain) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        ProviderAnnotations.getInterfaceName(IltProvider.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{
                                                                                                Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                           provisionedAccessControlEntriesAsJson);
}
 
Example 4
Source File: MyRadioProviderApplication.java    From joynr with Apache License 2.0 6 votes vote down vote up
private static void provisionAccessControl(Properties properties, String domain) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        ProviderAnnotations.getInterfaceName(MyRadioProvider.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{
                                                                                                Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                           provisionedAccessControlEntriesAsJson);
}
 
Example 5
Source File: AbstractBounceProxyServerTest.java    From joynr with Apache License 2.0 6 votes vote down vote up
private ObjectMapper getObjectMapper() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
    // true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    SimpleModule module = new SimpleModule("NonTypedModule", new Version(1, 0, 0, "", "", ""));
    module.addSerializer(new JoynrEnumSerializer());
    module.addSerializer(new JoynrListSerializer());

    TypeDeserializer typeDeserializer = joynrTypeResolverBuilder.buildTypeDeserializer(objectMapper.getDeserializationConfig(),
                                                                                       SimpleType.construct(Object.class),
                                                                                       null);

    module.addDeserializer(Object.class, new JoynrUntypedObjectDeserializer(typeDeserializer));
    objectMapper.registerModule(module);
    return objectMapper;
}
 
Example 6
Source File: MyGpsProviderApplication.java    From joynr with Apache License 2.0 6 votes vote down vote up
private static void provisionAccessControl(Properties properties, String domain) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        ProviderAnnotations.getInterfaceName(MyGpsProvider.class),
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{
                                                                                                Permission.YES });

    MasterAccessControlEntry[] provisionedAccessControlEntries = { newMasterAccessControlEntry };
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
    properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                           provisionedAccessControlEntriesAsJson);
}
 
Example 7
Source File: MessagingTest.java    From joynr with Apache License 2.0 6 votes vote down vote up
private ObjectMapper getObjectMapper() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,
    // true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    return objectMapper;
}
 
Example 8
Source File: ObjectMapperProvider.java    From icure-backend with GNU General Public License v2.0 6 votes vote down vote up
@Override
public ObjectMapper getContext(Class<?> type) {
	// TypeResolver
	SimpleAbstractTypeResolver abstractTypeResolver = new SimpleAbstractTypeResolver();
	abstractTypeResolver.addMapping(List.class, ArrayList.class);
	abstractTypeResolver.addMapping(Set.class, HashSet.class);
	abstractTypeResolver.addMapping(Map.class, HashMap.class);

	// Serializer
	DefaultSerializerProvider serializerProvider = new DefaultSerializerProvider.Impl();

	// Deserializer
	DeserializerFactoryConfig deserializerFactoryConfig = new DeserializerFactoryConfig().withAbstractTypeResolver(abstractTypeResolver);
	BeanDeserializerFactory deserializerFactory = new BeanDeserializerFactory(deserializerFactoryConfig);
	DefaultDeserializationContext.Impl deserializationContext = new DefaultDeserializationContext.Impl(deserializerFactory);

	// ObjectMapper
	ObjectMapper objectMapper = new ObjectMapper(null, serializerProvider, deserializationContext);
	objectMapper = objectMapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.OBJECT_AND_NON_CONCRETE, "type");
	objectMapper = objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
	objectMapper = objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);

	return objectMapper;
}
 
Example 9
Source File: StaticCapabilitiesProvisioningTest.java    From joynr with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    Field objectMapperField = CapabilityUtils.class.getDeclaredField("objectMapper");
    objectMapperField.setAccessible(true);
    objectMapperField.set(CapabilityUtils.class, objectMapper);
}
 
Example 10
Source File: JsonMessageSerializerModule.java    From joynr with Apache License 2.0 5 votes vote down vote up
public JsonMessageSerializerModule() {
    objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, false);
    objectMapper.configure(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY, true);
    // objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
    objectMapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, true);
    objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
    objectMapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true);

    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    TypeResolverBuilder<?> joynrTypeResolverBuilder = objectMapper.getSerializationConfig()
                                                                  .getDefaultTyper(SimpleType.construct(Object.class));

    SimpleModule module = new SimpleModule("NonTypedModule", new Version(1, 0, 0, "", "", ""));
    module.addSerializer(new JoynrEnumSerializer());
    module.addSerializer(new JoynrListSerializer());
    module.addSerializer(new JoynrArraySerializer());

    TypeDeserializer typeDeserializer = joynrTypeResolverBuilder.buildTypeDeserializer(objectMapper.getDeserializationConfig(),
                                                                                       SimpleType.construct(Object.class),
                                                                                       null);

    module.addDeserializer(Request.class, new RequestDeserializer(objectMapper));
    module.addDeserializer(OneWayRequest.class, new OneWayRequestDeserializer(objectMapper));
    module.addDeserializer(Object.class, new JoynrUntypedObjectDeserializer(typeDeserializer));

    module.setMixInAnnotation(Throwable.class, ThrowableMixIn.class);
    objectMapper.registerModule(module);
}
 
Example 11
Source File: CapabilitiesUtilsTest.java    From joynr with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    Field objectMapperField = CapabilityUtils.class.getDeclaredField("objectMapper");
    objectMapperField.setAccessible(true);
    objectMapperField.set(CapabilityUtils.class, objectMapper);
}
 
Example 12
Source File: DefaultJoynrRuntimeFactory.java    From joynr with Apache License 2.0 5 votes vote down vote up
private void provisionAccessControl(Properties properties, String domain, String[] interfaceNames) {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    List<MasterAccessControlEntry> allEntries = new ArrayList<>();
    for (String interfaceName : interfaceNames) {
        MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                            domain,
                                                                                            interfaceName,
                                                                                            TrustLevel.LOW,
                                                                                            new TrustLevel[]{
                                                                                                    TrustLevel.LOW },
                                                                                            TrustLevel.LOW,
                                                                                            new TrustLevel[]{
                                                                                                    TrustLevel.LOW },
                                                                                            "*",
                                                                                            Permission.YES,
                                                                                            new Permission[]{
                                                                                                    joynr.infrastructure.DacTypes.Permission.YES });
        allEntries.add(newMasterAccessControlEntry);
    }
    MasterAccessControlEntry[] provisionedAccessControlEntries = allEntries.toArray(new MasterAccessControlEntry[allEntries.size()]);
    String provisionedAccessControlEntriesAsJson;
    try {
        provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries);
        properties.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                               provisionedAccessControlEntriesAsJson);
    } catch (JsonProcessingException e) {
        logger.error("Error parsing JSON.", e);
    }
}
 
Example 13
Source File: ServersUtil.java    From joynr with Apache License 2.0 5 votes vote down vote up
private static String createJsonFor(String directoriesUrl) throws JsonProcessingException {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    setObjectMapperOnCapabilitiesUtils(objectMapper);
    String channelId = "discoverydirectory_channelid";
    String participantId = "capabilitiesdirectory_participantid";
    GlobalDiscoveryEntry discoveryEntry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1),
                                                                                  "io.joynr",
                                                                                  GlobalCapabilitiesDirectory.INTERFACE_NAME,
                                                                                  participantId,
                                                                                  new ProviderQos(),
                                                                                  System.currentTimeMillis(),
                                                                                  Long.MAX_VALUE,
                                                                                  "",
                                                                                  new ChannelAddress(directoriesUrl,
                                                                                                     channelId));
    String accessParticipantId = "domainaccesscontroller_participantid";
    GlobalDiscoveryEntry accessControlEntry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1),
                                                                                      "io.joynr",
                                                                                      GlobalDomainAccessController.INTERFACE_NAME,
                                                                                      accessParticipantId,
                                                                                      new ProviderQos(),
                                                                                      System.currentTimeMillis(),
                                                                                      Long.MAX_VALUE,
                                                                                      "",
                                                                                      new InProcessAddress());
    List<DiscoveryEntry> entries = new ArrayList<>();
    entries.add(discoveryEntry);
    entries.add(accessControlEntry);
    return objectMapper.writeValueAsString(entries);
}
 
Example 14
Source File: JoynrEnd2EndTest.java    From joynr with Apache License 2.0 5 votes vote down vote up
protected static void provisionPermissiveAccessControlEntry(String domain, String interfaceName) throws Exception {
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
    List<MasterAccessControlEntry> provisionedAccessControlEntries = new ArrayList<MasterAccessControlEntry>();
    String existingAccessControlEntriesJson = System.getProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES);
    if (existingAccessControlEntriesJson != null) {
        provisionedAccessControlEntries.addAll(Arrays.asList(objectMapper.readValue(existingAccessControlEntriesJson,
                                                                                    MasterAccessControlEntry[].class)));
    }

    MasterAccessControlEntry newMasterAccessControlEntry = new MasterAccessControlEntry("*",
                                                                                        domain,
                                                                                        interfaceName,
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        TrustLevel.LOW,
                                                                                        new TrustLevel[]{
                                                                                                TrustLevel.LOW },
                                                                                        "*",
                                                                                        Permission.YES,
                                                                                        new Permission[]{
                                                                                                Permission.YES });

    provisionedAccessControlEntries.add(newMasterAccessControlEntry);
    String provisionedAccessControlEntriesAsJson = objectMapper.writeValueAsString(provisionedAccessControlEntries.toArray());
    System.setProperty(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES,
                       provisionedAccessControlEntriesAsJson);
}
 
Example 15
Source File: MvccEntitySerializationStrategyV1Impl.java    From usergrid with Apache License 2.0 5 votes vote down vote up
public EntitySerializer() {
    try {
        mapper = new ObjectMapper( f );
        //                mapper.enable(SerializationFeature.INDENT_OUTPUT); don't indent output,
        // causes slowness
        mapper.enableDefaultTypingAsProperty( ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, "@class" );
    }
    catch ( Exception e ) {
        throw new RuntimeException( "Error setting up mapper", e );
    }
}
 
Example 16
Source File: CpEntityMapUtilsTest.java    From usergrid with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerialization() throws JsonProcessingException, IOException {

    Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
        put( "username", "bart" );
        put( "email", "[email protected]" );
        put( "block", new ArrayList<Object>() {{
            add( new LinkedHashMap<String, Object>() {{ put("name", "fred"); }});
            add( new LinkedHashMap<String, Object>() {{ put("name", "gertrude"); }});
            add( new LinkedHashMap<String, Object>() {{ put("name", "mina"); }});
        }});
        put( "blockedBy", new ArrayList<Object>() {{
            add( new LinkedHashMap<String, Object>() {{ put("name", "isabell"); }});
        }});
        put( "location", new LinkedHashMap<String, Object>() {{
            put("latitude", 37.776753 );
            put("longitude", -122.407846 );
        }});
    }};

    org.apache.usergrid.persistence.model.entity.Entity entity =
        new org.apache.usergrid.persistence.model.entity.Entity(
            new SimpleId( "user" ) );
    entity = CpEntityMapUtils.fromMap( entity, properties, null, true );

    assertUserWithBlocks( entity );

    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, "@class");

    String entityString = mapper.writeValueAsString( entity );
    //log.debug("Serialized to JSON: " + entityString );

    TypeReference<Entity> tr = new TypeReference<Entity>() {};
    entity = mapper.readValue( entityString, tr );
    //log.debug("Round-tripped entity: " + CpEntityMapUtils.toMap(entity) );

    assertUserWithBlocks( entity );
}
 
Example 17
Source File: SimpleFileBasedMessagePersister.java    From joynr with Apache License 2.0 4 votes vote down vote up
public SimpleFileBasedMessagePersister() {
    objectMapper = new ObjectMapper();
    objectMapper.enableDefaultTypingAsProperty(DefaultTyping.JAVA_LANG_OBJECT, "_typeName");
}
 
Example 18
Source File: CpEntityMapUtilsTest.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@Test
public void testNestedArraySerialization() throws JsonProcessingException, IOException {

    /*** This tests example property input of

     {
     "nestedarray" : [ [ "fred" ] ]
     }

     ****/

    Map<String, Object> properties = new LinkedHashMap<String, Object>() {{
        put( "nestedarray",
            new ArrayList<ArrayList<String>>() {{
                add(0, new ArrayList<String>() {{
                    add(0, "fred");
                }});
            }}
        );
        put( "block", new ArrayList<Object>() {{
            add( new LinkedHashMap<String, Object>() {{ put("name", "fred"); }});
            add( new LinkedHashMap<String, Object>() {{ put("name", "gertrude"); }});
            add( new LinkedHashMap<String, Object>() {{ put("name", "mina"); }});
        }});
    }};

    org.apache.usergrid.persistence.model.entity.Entity entity =
        new org.apache.usergrid.persistence.model.entity.Entity(
            new SimpleId( "user" ) );
    entity = CpEntityMapUtils.fromMap( entity, properties, null, true );

    assertUserWithBlocks( entity );

    ObjectMapper mapper = new ObjectMapper();
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.enableDefaultTypingAsProperty(ObjectMapper.DefaultTyping.JAVA_LANG_OBJECT, "@class");

    String entityString = mapper.writeValueAsString( entity );
    //log.debug("Serialized to JSON: " + entityString );

    TypeReference<Entity> tr = new TypeReference<Entity>() {};
    entity = mapper.readValue( entityString, tr );
    //log.debug("Round-tripped entity: " + CpEntityMapUtils.toMap(entity) );

    assertUserWithBlocks( entity );
}