public static Environment resolveAnyOfEnvironment(
      Environment environment, String... preferredEnvironmentTypes) {
    List<Environment> allEnvironments = expandAnyOfEnvironments(environment);
    for (String urn : preferredEnvironmentTypes) {
      for (Environment env : allEnvironments) {
        if (urn.equals(env.getUrn())) {
          return env;
        }
      }
    }
    return allEnvironments.iterator().next();
  }
@Test
  public void testResolveAnyOfEnvironment() {
    Environment dockerEnv = Environments.createDockerEnvironment("A");
    Environment processEnv =
        Environments.createProcessEnvironment("os", "arch", "cmd", new HashMap<>());
    Environment env =
        Environments.createAnyOfEnvironment(
            dockerEnv, Environments.createAnyOfEnvironment(processEnv));
    assertThat(
        Environments.resolveAnyOfEnvironment(
            env, BeamUrns.getUrn(StandardEnvironments.Environments.DOCKER)),
        equalTo(dockerEnv));
    assertThat(
        Environments.resolveAnyOfEnvironment(
            env, BeamUrns.getUrn(StandardEnvironments.Environments.PROCESS)),
        equalTo(processEnv));
    assertThat(
        Environments.resolveAnyOfEnvironment(
            env, BeamUrns.getUrn(StandardEnvironments.Environments.EXTERNAL)),
        notNullValue());
  }