DockerCloudUtils { @Nullable public static String getEnvParameter(@Nonnull AgentDescription agentDescription, @Nonnull String name) { requireNonNull(agentDescription, "Agent description cannot be null."); requireNonNull(name, "Environment variable name cannot be null."); return agentDescription.getAvailableParameters().get("env." + name); }  @Nonnull static T requireNonNull(T obj, @Nonnull String msg); @Nonnull static T requireNonNull(T obj, @Nonnull Supplier<String> msgSupplier); @Nullable static UUID getClientId(@Nonnull AgentDescription agentDescription); @Nullable static UUID getImageId(@Nonnull AgentDescription agentDescription); @Nullable static UUID getInstanceId(@Nonnull AgentDescription agentDescription); @Nullable static UUID tryParseAsUUID(@Nullable String value); @Nonnull static String toShortId(@Nonnull String id); @Nonnull static Logger getLogger(@Nonnull Class<?> cls); @Nullable static String getEnvParameter(@Nonnull AgentDescription agentDescription, @Nonnull String name); @Nonnull static String readUTF8String(@Nonnull InputStream inputStream); @Nonnull static String readUTF8String(@Nonnull InputStream inputStream, int maxByteLength); static boolean hasImageTag(@Nonnull String image); static long toUnsignedLong(int value); @Nonnull static String getStackTrace(@Nullable Throwable throwable); @Nonnull static Map<String, String> extractTCPluginParams(@Nonnull HttpServletRequest request); static boolean isDebugEnabled(); static boolean isDefaultDockerSocketAvailable(); static boolean isDefaultDockerNamedPipeAvailable(); static boolean isWindowsHost(); @Nonnull @SafeVarargs static Map<K,V> immutableMapOf(@Nonnull Pair<K,V>... pairs); @Nonnull @SafeVarargs static Map<K,V> mapOf(@Nonnull Pair<K,V>... pairs); @Nonnull static Pair<K,V> pair(@Nonnull K key, @Nonnull V value); static final String NS; static final String NS_PREFIX; static final String CLIENT_ID_LABEL; static final String INSTANCE_ID_LABEL; static final String SOURCE_IMAGE_ID_LABEL; static final String TEST_INSTANCE_ID_LABEL; static final String CLOUD_TYPE_PARAM; static final String CLIENT_UUID_PARAM; static final String SERVER_URL_PARAM; static final String IMAGES_PARAM; static final String TEST_IMAGE_PARAM; static final String USE_DEFAULT_UNIX_SOCKET_PARAM; static final String USE_DEFAULT_WIN_NAMED_PIPE_PARAM; static final String INSTANCE_URI; static final String USE_TLS; static final String AGENT_RUNTIME_ID_AGENT_CONF; static final URI DOCKER_DEFAULT_SOCKET_URI; static final URI DOCKER_DEFAULT_NAMED_PIPE_URI; static final DockerAPIVersion DOCKER_API_TARGET_VERSION; static final DockerAPIVersion DOCKER_API_MIN_VERSION; static final String DEBUG_SYSPROP; static final String ENV_PREFIX; static final String ENV_CLIENT_ID; static final String ENV_IMAGE_ID; static final String ENV_INSTANCE_ID; static final String ENV_AGENT_PARAMS; static final String ENV_TEST_INSTANCE_ID; static final String ENV_SERVER_URL; static final String TC_PROPERTY_PREFIX; }
@Test public void getEnvParameter() { AgentDescription description = new TestSBuildAgent(). environmentVariable("ABC", "123"). environmentVariable("CDF", "456"); assertThat(DockerCloudUtils.getEnvParameter(description, "ABC")).isEqualTo("123"); assertThat(DockerCloudUtils.getEnvParameter(description, "CDF")).isEqualTo("456"); assertThat(DockerCloudUtils.getEnvParameter(description, "EFG")).isNull(); }
@Test public void getEnvParameterWithNullArguments() { AgentDescription description = new TestSBuildAgent(). environmentVariable("ABC", "123"). environmentVariable("CDF", "456"); assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> DockerCloudUtils.getEnvParameter(description, null)); assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> DockerCloudUtils.getEnvParameter(null, "ABC")); }