@Test
public void testPopulateServicePackagesInfo() throws Exception {

  Capture<AmbariManagementController> controllerCapture = EasyMock.newCapture();
  Injector injector = createStrictMock(Injector.class);
  MaintenanceStateHelper maintHelper = createNiceMock(MaintenanceStateHelper.class);
  ServiceInfo serviceInfo = createNiceMock(ServiceInfo.class);
  Map<String, String> hostParams = new HashMap<String, String>();
  String osFamily = "testOSFamily";
  Map<String, ServiceOsSpecific> osSpecifics = new HashMap<String, ServiceOsSpecific>();
  ServiceOsSpecific.Package package1 = new ServiceOsSpecific.Package();
  package1.setName("testrpm1");
  ServiceOsSpecific.Package package2 = new ServiceOsSpecific.Package();
  package2.setName("testrpm2");
  ServiceOsSpecific.Package package3 = new ServiceOsSpecific.Package();
  package3.setName("testrpm3");
  List<ServiceOsSpecific.Package> packageList1 = new ArrayList<ServiceOsSpecific.Package>();
  packageList1.add(package1);
  List<ServiceOsSpecific.Package> packageList2 = new ArrayList<ServiceOsSpecific.Package>();
  packageList2.add(package2);
  packageList2.add(package3);
  ServiceOsSpecific osSpecific1 = new ServiceOsSpecific("testOSFamily");
  osSpecific1.addPackages(packageList1);
  ServiceOsSpecific osSpecific2 = new ServiceOsSpecific("testOSFamily1,testOSFamily,testOSFamily2");
  osSpecific2.addPackages(packageList2);
  osSpecifics.put("testOSFamily", osSpecific1);
  osSpecifics.put("testOSFamily1,testOSFamily,testOSFamily2", osSpecific2);
  expect(serviceInfo.getOsSpecifics()).andReturn(osSpecifics);
  injector.injectMembers(capture(controllerCapture));
  expect(injector.getInstance(Gson.class)).andReturn(null);
  expect(injector.getInstance(MaintenanceStateHelper.class)).andReturn(maintHelper).anyTimes();
  expect(injector.getInstance(KerberosHelper.class)).andReturn(createNiceMock(KerberosHelper.class));
  replay(maintHelper, injector, clusters, serviceInfo);
  AmbariManagementControllerImplTest.NestedTestClass nestedTestClass = this.new NestedTestClass(null, clusters,
      injector);
  ServiceOsSpecific serviceOsSpecific = nestedTestClass.populateServicePackagesInfo(serviceInfo, hostParams, osFamily);
  assertEquals(serviceOsSpecific.getPackages().size(), 3);
}