@Test
  public void willRequireContainerPortWhenContainerized() throws Exception {
    config.setDocker(
        new DockerConfigProperties() {
          {
            setImage("test");
          }
        });
    config.setResources(
        new ResourcesConfigProperties() {
          {
            setPorts(
                Collections.singletonMap(
                    "test",
                    new ResourcePortConfigProperties() {
                      {
                        setHost("ANY");
                      }
                    }));
          }
        });

    validator.validate(config, errors);

    assertEquals(
        "resources.ports.test.container.empty", errors.getFieldError("resources.ports").getCode());
  }
  @Test
  public void willRejectMemIfNegative() throws Exception {
    config.setResources(new ResourcesConfigProperties());
    config.getResources().setMem(-128.0);

    validator.validate(config, errors);
    assertEquals("resources.mem.not_positive", errors.getFieldError("resources.mem").getCode());
  }
  @Test
  public void willRejectIfZookeeperIsEmpty() throws Exception {
    config.setZookeeper(new ZookeeperConfigProperties());
    config.getZookeeper().setServer(" ");

    validator.validate(config, errors);
    assertEquals("zookeeper.server.empty", errors.getFieldError("zookeeper.server").getCode());
  }
  @Test
  public void willRejectIfMasterIsEmpty() throws Exception {
    config.setMaster(" ");

    validator.validate(config, errors);
    assertEquals("master.empty", errors.getFieldError("master").getCode());
  }
  @Test
  public void willNotRejectAGoodConfiguration() throws Exception {
    config.setMaster("leader.mesos:5050");
    config.setZookeeper(
        new ZookeeperConfigProperties() {
          {
            setServer("leader.mesos:2181");
          }
        });
    config.setResources(
        new ResourcesConfigProperties() {
          {
            setCpus(1.0);
            setMem(128);
          }
        });

    validator.validate(config, errors);

    assertEquals(0, errors.getErrorCount());
  }
  @Test
  public void willRequireHostPort() throws Exception {
    config.setResources(
        new ResourcesConfigProperties() {
          {
            setPorts(
                Collections.singletonMap(
                    "test",
                    new ResourcePortConfigProperties() {
                      {
                        setContainer(1);
                      }
                    }));
          }
        });

    validator.validate(config, errors);

    assertEquals(
        "resources.ports.test.host.empty", errors.getFieldError("resources.ports").getCode());
  }