@Test
public void testFilterWithState() throws Exception {

  ServiceContext sc = new MockRunningServiceContext(rule,
      TestServiceManager.createBaseDef("service"));
  GetCompInstancesRequestProto.Builder reqBuilder =
      GetCompInstancesRequestProto.newBuilder();
  reqBuilder.addAllContainerStates(Lists.newArrayList(
      ContainerState.READY.toString()));
  List<ComponentContainers> compContainers = FilterUtils.filterInstances(sc,
      reqBuilder.build());
  Assert.assertEquals("num comps", 2, compContainers.size());
  compContainers.forEach(item -> {
    Assert.assertEquals("num containers", 2, item.getContainers().size());
  });
  reqBuilder.clearContainerStates();
  reqBuilder.addAllContainerStates(Lists.newArrayList(
      ContainerState.STOPPED.toString()));
  Assert.assertEquals("num comps", 0,
      FilterUtils.filterInstances(sc, reqBuilder.build()).size());
}