### Question:
Utilities { public static void generateInvocationIdIfNecessary(final TraceeBackend backend) { if (backend != null && !backend.containsKey(TraceeConstants.INVOCATION_ID_KEY) && backend.getConfiguration().shouldGenerateInvocationId()) { backend.put(TraceeConstants.INVOCATION_ID_KEY, Utilities.createRandomAlphanumeric(backend.getConfiguration().generatedInvocationIdLength())); } } private  Utilities(); static boolean isNullOrEmptyString(final String value); static String createRandomAlphanumeric(final int length); static String createAlphanumericHash(final String str, final int length); static void generateInvocationIdIfNecessary(final TraceeBackend backend); static void generateSessionIdIfNecessary(final TraceeBackend backend, final String sessionId); static final Charset CHARSET_UTF8; }### Answer:
@Test public void ignoreInvocationIdGenerationIfBackendIsNull() { Utilities.generateInvocationIdIfNecessary(null); assertTrue("No exception occurred", true); }
@Test public void dontGenerateInvocationIdIfPresentInBackend() { final TraceeBackend backend = SimpleTraceeBackend.createNonLoggingAllPermittingBackend(); backend.put(INVOCATION_ID_KEY, "ourTestId"); Utilities.generateInvocationIdIfNecessary(backend); assertThat(backend.get(INVOCATION_ID_KEY), is("ourTestId")); }
@Test public void generateInvocationIdIfNotPresentInBackend() { final TraceeBackend backend = SimpleTraceeBackend.createNonLoggingAllPermittingBackend(); Utilities.generateInvocationIdIfNecessary(backend); assertThat(backend.get(INVOCATION_ID_KEY), not(isEmptyOrNullString())); }