*/
public class PersistenceManagerImplTest {
@Test
public void testCreate() 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);
RequestBody body = new RequestBody();
Map<Resource.Type, String> mapResourceIds = new HashMap<Resource.Type, String>();
mapResourceIds.put(Resource.Type.Cluster, "clusterId");
mapResourceIds.put(Resource.Type.Service, "serviceId");
Map<String, Object> mapProperties = new HashMap<String, Object>();
mapProperties.put("componentId", "id");
mapProperties.put(PropertyHelper.getPropertyId("foo", "bar"), "value");
NamedPropertySet namedPropSet = new NamedPropertySet("", mapProperties);
body.addPropertySet(namedPropSet);
Set<Map<String, Object>> setExpected = new HashSet<Map<String, Object>>();
Map<String, Object> mapExpected = new HashMap<String, Object>(mapProperties);
mapExpected.put(clusterId, "clusterId");
mapExpected.put(serviceId, "serviceId");
setExpected.add(mapExpected);
//expectations
expect(resource.getIds()).andReturn(mapResourceIds);
expect(resource.getResourceDefinition()).andReturn(resourceDefinition).atLeastOnce();
expect(resourceDefinition.getType()).andReturn(Resource.Type.Component);
expect(controller.getSchema(Resource.Type.Component)).andReturn(schema);
expect(schema.getKeyPropertyId(Resource.Type.Cluster)).andReturn(clusterId);
expect(schema.getKeyPropertyId(Resource.Type.Service)).andReturn(serviceId);