Messages { public static IOTransition.IOLetter fullLetter(String message) { Matcher matcher = lettersPattern.matcher(message); if (matcher.matches()) { if (matcher.group(1).equals("^")) { if (matcher.group(2) == null) { return new IOTransition.IOLetter(new Message(matcher.group(5), matcher.group(5), matcher.group(6)), IOAlphabetType.INTERNAL); } else { if (matcher.group(4).equals("->")) { return new IOTransition.IOLetter(new Message(matcher.group(3), matcher.group(5), matcher.group(6)), IOAlphabetType.INTERNAL); } else { return new IOTransition.IOLetter(new Message(matcher.group(5), matcher.group(3), matcher.group(6)), IOAlphabetType.INTERNAL); } } } if (matcher.group(1).equals("!")) { if (matcher.group(4).equals("->")) { return new IOTransition.IOLetter(new Message(matcher.group(3), matcher.group(5), matcher.group(6)), IOAlphabetType.OUTPUT); } else { return new IOTransition.IOLetter(new Message(matcher.group(5), matcher.group(3), matcher.group(6)), IOAlphabetType.OUTPUT); } } else { if (matcher.group(4).equals("->")) { return new IOTransition.IOLetter(new Message(matcher.group(3), matcher.group(5), matcher.group(6)), IOAlphabetType.INPUT); } else { return new IOTransition.IOLetter(new Message(matcher.group(5), matcher.group(3), matcher.group(6)), IOAlphabetType.INPUT); } } } throw rejectLetter(message); }  static Message message(String message); static IOTransition.IOLetter letter(String message); static IOTransition.IOLetter fullLetter(String message);  }
@Test public void canBuildAnFullInternalLetterWithToFromAndContentDefined() throws Exception { IOTransition.IOLetter letter = Messages.fullLetter("^a->b.m"); Assertions.assertThat(letter.label.toString()).isEqualTo("a -> b.m"); Assertions.assertThat(letter.type).isEqualTo(IOAlphabetType.INTERNAL); }
@Test public void canBuildAnFullInternalLetterWithReverseArrow() throws Exception { IOTransition.IOLetter letter = Messages.fullLetter("^a<-b.m"); Assertions.assertThat(letter.label.toString()).isEqualTo("b -> a.m"); Assertions.assertThat(letter.type).isEqualTo(IOAlphabetType.INTERNAL); }