<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Lê Trọng Tân</title>
    <description>The latest articles on DEV Community by Lê Trọng Tân (@letrongtanbs).</description>
    <link>https://dev.to/letrongtanbs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F213721%2F1ac77726-c8ea-486e-bf50-66ac9c3c5334.jpeg</url>
      <title>DEV Community: Lê Trọng Tân</title>
      <link>https://dev.to/letrongtanbs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/letrongtanbs"/>
    <language>en</language>
    <item>
      <title>Mockito Predicate JPA in unit testing not run correctly</title>
      <dc:creator>Lê Trọng Tân</dc:creator>
      <pubDate>Mon, 20 Jul 2020 23:10:34 +0000</pubDate>
      <link>https://dev.to/letrongtanbs/mockito-predicate-jpa-in-unit-testing-not-run-correctly-5ab8</link>
      <guid>https://dev.to/letrongtanbs/mockito-predicate-jpa-in-unit-testing-not-run-correctly-5ab8</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;div class="ltag__stackexchange--header"&gt;
          &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
          &lt;a href="https://stackoverflow.com/questions/62990439/mockito-predicate-jpa-not-run-correctly" rel="noopener noreferrer"&gt;
            Mockito Predicate JPA not run correctly
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Jul 20 '20&lt;/span&gt;
            &lt;span&gt;Comments: 3&lt;/span&gt;
            &lt;span&gt;Answers: 1&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/62990439/mockito-predicate-jpa-not-run-correctly" rel="noopener noreferrer"&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          2
        &lt;/div&gt;
        &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fstackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;In Unit Test Class:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    @Mock
    EntityManager entityManager
    @Mock
    Root&amp;lt;RedFox&amp;gt; redFoxRoot;

    @Mock
    Expression expression;

    @Mock
    Path path;

    @Mock
    Predicate predicate;

    @Test 
    public void filterTest(){
      TypedQuery&amp;lt;RedFox&amp;gt; redFoxQuery = (TypedQuery&amp;lt;RedFox&amp;gt;) Mockito.mock(TypedQuery.class);

      CriteriaQuery&amp;lt;RedFox&amp;gt; redFoxCriteriaQuery = Mockito.mock(CriteriaQuery.class);

      Mockito.when(redFoxCriteriaQuery.where(Mockito.any(Predicate[].class)))
      .thenReturn(redFoxQuery); 
 
      Mockito.when(redFoxCriteriaQuery.orderBy(Mockito.anyList())).thenReturn(redFoxCriteriaQuery);

      CriteriaBuilder builder = Mockito.mock(CriteriaBuilder.class);

      Mockito.when(redFoxRoot.get("isDeleted")).thenReturn(path);

      Mockito.when(path.isNull()).thenReturn(predicate);

      Mockito.when(builder.literal(Mockito.any())).thenReturn(expression);

      Mockito.when(redFoxCriteriaQuery.from(RedFox.class)).thenReturn(redFoxRoot);      
 
      Mockito.when(entityManager.createQuery(redFoxCriteriaQuery)).thenReturn(redFoxQuery);

      List&amp;lt;RedFox&amp;gt; redFoxs = new ArrayList&amp;lt;&amp;gt;();
      RedFox&lt;/code&gt;&lt;/pre&gt;…
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    &lt;a href="https://stackoverflow.com/questions/62990439/mockito-predicate-jpa-not-run-correctly" class="ltag__stackexchange--btn" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Kotlin web project</title>
      <dc:creator>Lê Trọng Tân</dc:creator>
      <pubDate>Sat, 17 Aug 2019 23:25:18 +0000</pubDate>
      <link>https://dev.to/letrongtanbs/kotlin-web-project-3jm4</link>
      <guid>https://dev.to/letrongtanbs/kotlin-web-project-3jm4</guid>
      <description>&lt;p&gt;Does anyone know how to build a website with Kotlin, Spring boot, Mybatis, and Gradle?&lt;br&gt;
I have to create a web page with these kinds of things. If you know how please teach me. Now I stuck with step create a database connection and sometimes the configuration not working on IntelliJ IDEA when I ran some bash.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
