DockerCloudUtils { @Nonnull public static String toShortId(@Nonnull String id) { requireNonNull(id, "ID cannot be null."); return id.substring(0, Math.min(id.length(), 12)); }  @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 toShortId() { assertThat(DockerCloudUtils.toShortId("1abe11edbeef0000000000000000000000")).isEqualTo("1abe11edbeef"); }
@Test public void toShortIdUnderflow() { assertThat(DockerCloudUtils.toShortId("beef")).isEqualTo("beef"); assertThat(DockerCloudUtils.toShortId("")).isEqualTo(""); }
@Test public void toShortIdWithNullInput() { assertThatExceptionOfType(NullPointerException.class).isThrownBy(() -> DockerCloudUtils.toShortId(null)); }