/** * {@inheritDoc} */ @Override public void accept(final TemplateVisitor visitor) { delegate().accept(new SafeTemplateVisitor(visitor)); } }
@Override protected void processTemplate(final ResourceTemplate template) { library.accept( new TemplateConsumer() { @Override protected void processTemplate(final ResourceTemplate other) { if(template!=other) { assertThat(other,not(equalTo(template))); } } } ); } }
@Test public void testContainsTemplates() { final TemplateLibrary library=getLibrary(); library.accept( new TemplateConsumer() { @Override protected void processTemplate(ResourceTemplate template) { assertThat(library.contains(template),equalTo(true)); } } ); }
@Test public void testFindsTemplatesById() { final TemplateLibrary library=getLibrary(); library.accept( new TemplateConsumer() { @Override protected void processTemplate(ResourceTemplate template) { ResourceTemplate other = library.findById(template.id()); assertThat(other,not(nullValue())); } } ); }
@Test public void testFindsTemplatesById() { final TemplateLibrary library=getLibrary(); library.accept( new TemplateConsumer() { @Override protected void processTemplate(ResourceTemplate template) { ResourceTemplate other = library.findById(template.id()); assertThat(other,equalTo(template)); } } ); }
@Test public void testFindsTemplatesByHandler() { final TemplateLibrary library=getLibrary(); library.accept( new TemplateConsumer() { @Override protected void processTemplate(ResourceTemplate template) { ResourceTemplate other = library.findByHandler(template.handlerClass()); assertThat(other,equalTo(template)); } } ); }
@Test public void testFindsTemplatesByHandler() { final TemplateLibrary library=getLibrary(); library.accept( new TemplateConsumer() { @Override protected void processTemplate(ResourceTemplate template) { ResourceTemplate other = library.findByHandler(template.handlerClass()); assertThat(other,not(nullValue())); } } ); }
@Test public void testTemplateHasCustomString() { TemplateLibrary library=getLibrary(); library.accept( new TemplateConsumer() { private void assertThatHasCustomString(Object obj) { assertThat(obj.toString(),not(equalTo(obj.getClass().getName()+"@"+System.identityHashCode(obj)))); } @Override protected void processTemplate(ResourceTemplate template) { assertThatHasCustomString(template); for(AttachedTemplate attachedTemplate:template.attachedTemplates()) { assertThatHasCustomString(attachedTemplate); } } } ); }
@Test public void testEqualsDifferent() { final TemplateLibrary library=getLibrary(); library.accept( new TemplateConsumer() { @Override protected void processTemplate(final ResourceTemplate template) { library.accept( new TemplateConsumer() { @Override protected void processTemplate(final ResourceTemplate other) { if(template!=other) { assertThat(other,not(equalTo(template))); } } } ); } } ); }