@Test
  public void testRegisterMpacks() throws Exception{
    MpackRequest mpackRequest = createNiceMock(MpackRequest.class);
    RequestStatusResponse response = new RequestStatusResponse(new Long(201));
    Mpack mpack = new Mpack();
    mpack.setResourceId((long)100);
    mpack.setModules(new ArrayList<Module>());
    mpack.setPrerequisites(new HashMap<String, String>());
    mpack.setRegistryId(new Long(100));
    mpack.setVersion("3.0");
    mpack.setMpackUri("abc.tar.gz");
    mpack.setDescription("Test mpack");
    mpack.setName("testMpack");
    MpackResponse mpackResponse = new MpackResponse(mpack);
    Injector injector = createNiceMock(Injector.class);
    expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(null).atLeastOnce();
    expect(ambariMetaInfo.registerMpack(mpackRequest)).andReturn(mpackResponse);
    ambariMetaInfo.init();
    expectLastCall();
    replay(ambariMetaInfo,injector);
    AmbariManagementController controller = new AmbariManagementControllerImpl(null, clusters, injector);
    setAmbariMetaInfo(ambariMetaInfo, controller);
    Assert.assertEquals(mpackResponse,controller.registerMpack(mpackRequest));
  }
Ensure that RollbackException is thrown outside the updateClusters method
when a unique constraint violation occurs.
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerImplTest.java