ContextName { public static String fromName(final String name) { if (!name.contains(".")) { throw new InvalidNameException("Invalid action or event name " + name); } else return name.split("\\.")[0]; } private  ContextName(); static String fromName(final String name);  }
@Test public void shouldReturnContextName() { assertThat(ContextName.fromName("test-context.command.test-command"), equalTo("test-context")); }
@Test(expected = InvalidNameException.class) public void shouldThrowExceptionWithInvalidActionName() { ContextName.fromName("test-context-commands-test-command"); }