title: How to prevent Thymeleaf Template Engine read path URL Get Mapping as a template engine name in Spring Boot
body: <p>I have a controller get mapping which read path variable to return object from repository, and return template engine name using Thymeleaf to show it, and it works well in localhost with postman and browser:</p>
  <pre><code>@Controller
  public class InvoiceFormController {
  
    @Autowired
    InvoiceDetailRepository invoiceDetailRepository;
  
    @Autowired
    InvoiceService invoiceService;
  
    @GetMapping(&quot;/supermarket/invoice/{id}&quot;)
    public String getInvoiceView(@PathVariable(&quot;id&quot;) UUID id, Model model) {
      InvoiceDetail invoiceDetail = invoiceDetailRepository.getInvoiceDetailById(id);
      if(invoiceDetail == null) {
        return invoiceService.showError(model);
      }
      return invoiceService.showDetail(invoiceDetail, model);
    }
  }
  </code></pre>
  <p>this is the service:</p>
  <pre><code>@Service
  public class InvoiceService {
  
      public Spring showDetail(InvoiceDetail invoiceDetail, Model model) {
        model.addAttribute(&quot;invoiceDetail&quot;, invoiceDetail);
        return &quot;invoicePage&quot;;
      }
  
      public Spring showError(Model model) {
        model.addAttribute(&quot;error&quot;, &quot;not found&quot;);
        return &quot;errorPage&quot;;
      }
  }
  </code></pre>
  <p>But, when I creating the unit test, it always became error, because the path url get mapping always read by Spring Boot as template engine name:</p>
  <pre><code>ERROR org.thymeleaf.TemplateEngine -[THYMELEAF][main] Exception processing template &quot;supermarket/invoice/d5afd278-db7c-4482-b992-c7440b522067&quot;: Error resolving template [supermarket/invoice/d5afd278-db7c-4482-b992-c7440b522067], template might not exist or might not be accessible by any of the configured Template Resolvers
  org.thymeleaf.exceptions.TemplateInputException: Error resolving template [supermarket/invoice/d5afd278-db7c-4482-b992-c7440b522067], template might not exist or might not be accessible by any of the configured Template Resolvers
  </code></pre>
  <p>the unit test is looks like this:</p>
  <pre><code>@WebMvcTest(InvoiceFormController.class)
  class InvoiceFormControllerTest {
  
    @Autowired
    private MockMvc mockMvc;
    @MockBean
    InvoiceDetailRepository invoiceDetailRepository;
    @MockBean
    InvoiceService invoiceService;
    @Mock
    Model model;
  
    @Test
    void testViewSuccess() throws Exception {
  
      InvoiceDetail invoiceDetail = InvoiceDetail.builder().id(UUID.fromString(&quot;d5afd278-db7c-4482-b992-c7440b522068&quot;).build();
  
      UUID id = UUID.fromString(&quot;d5afd278-db7c-4482-b992-c7440b522068&quot;);
  
      Mockito.when(invoiceDetailRepository.getInvoiceDetailById(id))
              .thenReturn(invoiceDetail);
  
      Mockito.when(invoiceService.showDetail(invoiceDetail, model))
              .thenReturn(&quot;invoicePage&quot;);
  
      mockMvc.perform(MockMvcRequestBuilders.get(&quot;/supermarket/invoice/&quot;+&quot;d5afd278-db7c-4482-b992-c7440b522068&quot;))
              .andExpect(MockMvcResultMatchers.status().isOk());
              .andExpect(MockMvcResultMatchers.view().name(&quot;invoicePage&quot;));
  }
  </code></pre>