@Test
public void testGetResources_instance() throws Exception {

  Set<String> propertyIds = new HashSet<String>();
  TreeMap<String, String> foreignKeys = new TreeMap<String, String>();
  foreignKeys.put("cluster", "500");
  Map<String, Object> childMap = new TreeMap<String, Object>();
  childMap.put("childKey", "childValue");
  Map<String, Object> child2Map = new TreeMap<String, Object>();
  childMap.put("child2", child2Map);
  child2Map.put("child2Key", "child2Value");
  Map<String, Object> child3Map = new TreeMap<String, Object>();
  child2Map.put("child3", child3Map);
  Map<String, Object> child4Map = new TreeMap<String, Object>();
  child3Map.put("child4", child4Map);
  child4Map.put("child4Key", "child4Value");
  Map<String, Object> artifact_data = new TreeMap<String, Object>();
  artifact_data.put("foo", "bar");
  artifact_data.put("child", childMap);
  Map<String, String> responseForeignKeys = new HashMap<String, String>();
  responseForeignKeys.put("cluster", "500");
  // expectations
  expect(controller.getClusters()).andReturn(clusters).anyTimes();
  expect(clusters.getCluster("test-cluster")).andReturn(cluster).anyTimes();
  expect(clusters.getClusterById(500L)).andReturn(cluster).anyTimes();
  expect(cluster.getClusterId()).andReturn(500L).anyTimes();
  expect(cluster.getClusterName()).andReturn("test-cluster").anyTimes();
  expect(request.getPropertyIds()).andReturn(propertyIds).anyTimes();
  expect(dao.findByNameAndForeignKeys(eq("test-artifact"), eq(foreignKeys))).andReturn(entity).once();
  expect(entity.getArtifactName()).andReturn("test-artifact").anyTimes();
  expect(entity.getForeignKeys()).andReturn(responseForeignKeys).anyTimes();
  expect(entity.getArtifactData()).andReturn(artifact_data).anyTimes();
  // end of expectation setting
  replay(dao, em, controller, request, clusters, cluster, entity, entity2);
  // test
  PredicateBuilder pb = new PredicateBuilder();
  Predicate predicate = pb.begin().property("Artifacts/cluster_name").equals("test-cluster").and().
      property("Artifacts/artifact_name").equals("test-artifact").end().toPredicate();
  Set<Resource> response = resourceProvider.getResources(request, predicate);
  assertEquals(1, response.size());
  Resource resource = response.iterator().next();
  Map<String, Map<String, Object>> responseProperties = resource.getPropertiesMap();
  assertEquals(5, responseProperties.size());
  Map<String, Object> artifactDataMap = responseProperties.get("artifact_data");
  assertEquals("bar", artifactDataMap.get("foo"));
  assertEquals("test-artifact", resource.getPropertyValue("Artifacts/artifact_name"));
  assertEquals("test-cluster", resource.getPropertyValue("Artifacts/cluster_name"));
  assertEquals("bar", resource.getPropertyValue("artifact_data/foo"));
  assertEquals("childValue", resource.getPropertyValue("artifact_data/child/childKey"));
  assertEquals("child2Value", resource.getPropertyValue("artifact_data/child/child2/child2Key"));
  assertEquals("child4Value", resource.getPropertyValue("artifact_data/child/child2/child3/child4/child4Key"));
}