@Test
public void testIsApplicable() throws Exception{

  final String clusterName = "c1";
  final Cluster cluster = EasyMock.createMock(Cluster.class);
  Map<String, Service> services = new HashMap<String, Service>(){{
    put("SERVICE1", null);
    put("SERVICE2", null);
    put("SERVICE3", null);
  }};
  expect(clusters.getCluster(anyString())).andReturn(cluster).atLeastOnce();
  expect(cluster.getServices()).andReturn(services).atLeastOnce();
  replay(clusters, cluster);
  AbstractCheckDescriptor check = new TestCheckImpl(PrereqCheckType.SERVICE);
  PrereqCheckRequest request = new PrereqCheckRequest(clusterName, UpgradeType.ROLLING);
  List<String> oneServiceList = new ArrayList<String>() {{
    add("SERVICE1");
  }};
  List<String> atLeastOneServiceList = new ArrayList<String>() {{
    add("SERVICE1");
    add("NON_EXISTED_SERVICE");
  }};
  List<String> allServicesList = new ArrayList<String>(){{
    add("SERVICE1");
    add("SERVICE2");
  }};
  List<String> nonExistedList = new ArrayList<String>(){{
    add("NON_EXISTED_SERVICE");
  }};
  // case, where we need at least one service to be present
  Assert.assertEquals(true, check.isApplicable(request, oneServiceList, false));
  Assert.assertEquals(true, check.isApplicable(request, atLeastOneServiceList, false));
  // case, where all services need to be present
  Assert.assertEquals(false, check.isApplicable(request,atLeastOneServiceList, true));
  Assert.assertEquals(true, check.isApplicable(request, allServicesList, true));
  // Case with empty list of the required services
  Assert.assertEquals(false, check.isApplicable(request, new ArrayList<String>(), true));
  Assert.assertEquals(false, check.isApplicable(request, new ArrayList<String>(), false));
  // Case with non existed services
  Assert.assertEquals(false, check.isApplicable(request, nonExistedList, false));
  Assert.assertEquals(false, check.isApplicable(request, nonExistedList, true));
}