GraphVariableHelper { public static void validateVariable(final String variable, final Object value) throws IllegalArgumentException { if (null == value) throw Graph.Variables.Exceptions.variableValueCanNotBeNull(); if (null == variable) throw Graph.Variables.Exceptions.variableKeyCanNotBeNull(); if (variable.isEmpty()) throw Graph.Variables.Exceptions.variableKeyCanNotBeEmpty(); } private  GraphVariableHelper(); static void validateVariable(final String variable, final Object value);  }
@Test public void shouldThrowIfValueIsNull() { try { GraphVariableHelper.validateVariable("test", null); fail("Should have thrown an exception when value is null"); } catch (Exception iae) { final Exception expected = Graph.Variables.Exceptions.variableValueCanNotBeNull(); assertEquals(expected.getClass(), iae.getClass()); assertEquals(expected.getMessage(), iae.getMessage()); } }
@Test public void shouldThrowIfKeyIsNull() { try { GraphVariableHelper.validateVariable(null, "test"); fail("Should have thrown an exception when key is null"); } catch (Exception iae) { final Exception expected = Graph.Variables.Exceptions.variableKeyCanNotBeNull(); assertEquals(expected.getClass(), iae.getClass()); assertEquals(expected.getMessage(), iae.getMessage()); } }
@Test public void shouldThrowIfKeyIsEmpty() { try { GraphVariableHelper.validateVariable("", "test"); fail("Should have thrown an exception when key is empty"); } catch (Exception iae) { final Exception expected = Graph.Variables.Exceptions.variableKeyCanNotBeEmpty(); assertEquals(expected.getClass(), iae.getClass()); assertEquals(expected.getMessage(), iae.getMessage()); } }