@Test
public void testCreateResources_TopologyValidationFails() throws Exception {

  Request request = createMock(Request.class);
  Set<Map<String, Object>> setProperties = getBlueprintTestProperties();
  Map<String, String> requestInfoProperties = getTestRequestInfoProperties();
  // set expectations
  expect(blueprintFactory.createBlueprint(setProperties.iterator().next(), null)).andReturn(blueprint).once();
  blueprint.validateRequiredProperties();
  expect(blueprint.getName()).andReturn(BLUEPRINT_NAME).atLeastOnce();
  blueprint.validateTopology();
  expectLastCall().andThrow(new InvalidTopologyException("test"));
  expect(request.getProperties()).andReturn(setProperties);
  expect(request.getRequestInfoProperties()).andReturn(requestInfoProperties);
  expect(dao.findByName(BLUEPRINT_NAME)).andReturn(null);
  replay(dao, entity, metaInfo, blueprintFactory, blueprint, request);
  // end expectations
  ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
      Resource.Type.Blueprint,
      PropertyHelper.getPropertyIds(Resource.Type.Blueprint),
      PropertyHelper.getKeyPropertyIds(Resource.Type.Blueprint),
      createMock(AmbariManagementController.class));
  AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver();
  ((ObservableResourceProvider)provider).addObserver(observer);
  try {
    provider.createResources(request);
    fail("Expected exception due to topology validation error");
  } catch (IllegalArgumentException e) {
    // expected
  }
  verify(dao, entity, blueprintFactory, metaInfo, request);
}