Patterns { public Pattern getPattern(final EntityId entityId) throws PatternSyntaxException { if (!entityId.getIsPattern()) { return null; } String id = entityId.getId(); Pattern pattern = cachedPatterns.get(id); if (pattern == null) { pattern = Pattern.compile(id); cachedPatterns.put(id, pattern); } return pattern; }  Pattern getPattern(final EntityId entityId); boolean hasType(final EntityId entityId); Predicate<EntityId> getFilterEntityId(EntityId searchEntityId);  }
@Test public void getPatternNullTest() { EntityId entityId = new EntityId("A", "string", false); assertNull(new Patterns().getPattern(entityId)); }
@Test public void getPatternTest() { EntityId entityId = new EntityId("A*", "string", true); assertNotNull(new Patterns().getPattern(entityId)); }
@Test public void getPatternWtihSamePatternTest() { EntityId entityId = new EntityId("A*", "string", true); Patterns patterns = new Patterns(); Pattern pattern = patterns.getPattern(entityId); assertEquals(pattern, patterns.getPattern(entityId)); }
@Test public void getPatternWtihNotSamePatternTest() { EntityId entityId = new EntityId("A*", "string", true); EntityId entityId2 = new EntityId("B*", "string", true); Patterns patterns = new Patterns(); Pattern pattern = patterns.getPattern(entityId); assertNotEquals(pattern, patterns.getPattern(entityId2)); }
@Test(expected = PatternSyntaxException.class) public void getPatternThrowPatternSyntaxExceptionTest() { EntityId entityId = new EntityId("]|,\\((", "string", true); Patterns patterns = new Patterns(); patterns.getPattern(entityId); }