code: @Test public void testPersist__MultipleResources() throws Exception {
    ResourceInstance resource=createMock(ResourceInstance.class);
    ResourceDefinition resourceDefinition=createMock(ResourceDefinition.class);
    ClusterController controller=createMock(ClusterController.class);
    Schema schema=createMock(Schema.class);
    String clusterId="clusterId";
    String serviceId="serviceId";
    Request serverRequest=createStrictMock(Request.class);
    Map<Resource.Type,String> mapResourceIds=new HashMap<Resource.Type,String>();
    mapResourceIds.put(Resource.Type.Cluster,"clusterId");
    mapResourceIds.put(Resource.Type.Service,"serviceId");
    Set<Map<String,Object>> setProperties=new HashSet<Map<String,Object>>();
    Map<String,Object> mapResourceProps1=new HashMap<String,Object>();
    mapResourceProps1.put(clusterId,"clusterId");
    mapResourceProps1.put(serviceId,"serviceId");
    mapResourceProps1.put(PropertyHelper.getPropertyId("foo","bar"),"value");
    Map<String,Object> mapResourceProps2=new HashMap<String,Object>();
    mapResourceProps2.put(clusterId,"clusterId");
    mapResourceProps2.put(serviceId,"serviceId2");
    mapResourceProps2.put(PropertyHelper.getPropertyId("foo","bar2"),"value2");
    setProperties.add(mapResourceProps1);
    setProperties.add(mapResourceProps2);
    expect(resource.getIds()).andReturn(mapResourceIds);
    expect(resource.getResourceDefinition()).andReturn(resourceDefinition);
    expect(resourceDefinition.getType()).andReturn(Resource.Type.Component);
    expect(controller.getSchema(Resource.Type.Component)).andReturn(schema);
    expect(schema.getKeyPropertyId(Resource.Type.Cluster)).andReturn(clusterId).times(2);
    expect(schema.getKeyPropertyId(Resource.Type.Service)).andReturn(serviceId).times(2);
    expect(controller.createResources(Resource.Type.Component,serverRequest)).andReturn(new RequestStatusImpl(null));
    replay(resource,resourceDefinition,controller,schema,serverRequest);
    new TestCreatePersistenceManager(controller,setProperties,serverRequest).persist(resource,setProperties);
    verify(resource,resourceDefinition,controller,schema,serverRequest);
  }
  