Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Will you please update your question with ready-to-go compilable code. Here's some code review suggestions:</p> <p>Issues with this question code:</p> <ul> <li>Article.java missing import: <em>org.springframework.beans.factory.annotation.Autowired</em></li> <li>Article.java missing import: <em>org.springframework.transaction.annotation.Transactional</em></li> <li>Article.java attribute syntax issue: <em>dbRequestHandler</em></li> <li>Article.java attribute syntax issue: <em>filesystemRequestHandler</em></li> <li>Article.java method has no initialized return statement: <em>articleDTO</em></li> </ul> <p>Here's what you maybe should use as you questionCode with the above issues fixed:</p> <p><strong>Article.java</strong></p> <pre><code>import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; public class Article { @Autowired private Object dbRequestHandler; @Autowired private Object filesystemRequestHandler; @Transactional public ArticleDTO getArticleContents() { // extractText() and then save the data in DTO // extractImages() and then save the data in DTO // some other calls to other databases to save data in dto ArticleDTO articleDTO = null; return articleDTO; } public void extractText() { // call to DB } public void extractImages() { // call to file system } } </code></pre> <p><em>IntegrationTest.java</em> is a poor name for a testClass because it's to generic. I would suggest ArticleTest for a java unit test.</p> <p><strong>ArticleTest.java</strong></p> <pre><code>import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.beans.factory.annotation.Autowired; @RunWith(PowerMockRunner.class) @PrepareForTest(ClassWithPrivate.class) public class ArticleTest { @InjectMocks private Article cut; @Mock private Object dbRequestHandler; @Mock private Object filesystemRequestHandler; @Test public void testeExtractImages() { /* Initialization */ Article articleMock = Mockito.spy(cut); /* Mock Setup */ Mockito.doNothing().when(articleMock).extractImages(); /* Test Method */ ArticleDTO result = cut.getArticleContents(); /* Asserts */ Assert.assertNull(result); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload