in src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletUpdateTest.java [138:175]
public void testMixinTypes() throws IOException, JsonException {
// create a node without mixin node types
final Map <String, String> props = new HashMap <String, String> ();
props.put("jcr:primaryType","nt:unstructured");
final String location = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, props);
// assert no mixins
String content = getContent(location + ".json", CONTENT_TYPE_JSON);
JsonObject json = JsonUtil.parseObject(content);
assertFalse("jcr:mixinTypes not expected to be set", json.containsKey("jcr:mixinTypes"));
// add mixin
props.clear();
props.put("jcr:mixinTypes", "mix:versionable");
testClient.createNode(location, props);
content = getContent(location + ".json", CONTENT_TYPE_JSON);
json = JsonUtil.parseObject(content);
assertTrue("jcr:mixinTypes expected after setting them", json.containsKey("jcr:mixinTypes"));
Object mixObject = json.get("jcr:mixinTypes");
assertTrue("jcr:mixinTypes must be an array", mixObject instanceof JsonArray);
JsonArray mix = (JsonArray) mixObject;
assertTrue("jcr:mixinTypes must have a single entry", mix.size() == 1);
assertEquals("jcr:mixinTypes must have correct value", "mix:versionable", mix.getString(0));
// remove mixin
props.clear();
props.put("jcr:mixinTypes@Delete", "-");
testClient.createNode(location, props);
content = getContent(location + ".json", CONTENT_TYPE_JSON);
json = JsonUtil.parseObject(content);
final boolean noMixins = !json.containsKey("jcr:mixinTypes") || json.getJsonArray("jcr:mixinTypes").size() == 0;
assertTrue("no jcr:mixinTypes expected after clearing it", noMixins);
}