{"id":5409,"date":"2023-09-28T12:50:58","date_gmt":"2023-09-28T11:50:58","guid":{"rendered":"https:\/\/www.baeldung.com\/java-mockito-mockedconstruction"},"modified":"2023-09-28T12:50:58","modified_gmt":"2023-09-28T11:50:58","slug":"overview-of-mockito-mockedconstruction","status":"publish","type":"post","link":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/2023\/09\/28\/overview-of-mockito-mockedconstruction\/","title":{"rendered":"Overview of Mockito MockedConstruction"},"content":{"rendered":"<p><img src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/01\/On-Baeldung-7-1024x536.jpg\" class=\"webfeedsFeaturedVisual wp-post-image\" alt=\"\" decoding=\"async\" style=\"float: left; margin-right: 5px;\" srcset=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/01\/On-Baeldung-7-1024x536.jpg 1024w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/01\/On-Baeldung-7-300x157.jpg 300w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/01\/On-Baeldung-7-768x402.jpg 768w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/01\/On-Baeldung-7-100x52.jpg 100w, https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/01\/On-Baeldung-7.jpg 1200w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><\/p>\n<h2 id=\"bd-overview\" data-id=\"overview\"><strong>1. Overview<\/strong><\/h2>\n<div class=\"bd-anchor\" id=\"overview\"><\/div>\n<p>When writing unit tests, sometimes we\u2019ll encounter a situation where it can be useful to return a mock when we construct a new object. For example, when testing legacy code with <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-coupling-classes-tight-loose\"  rel=\"noopener\">tightly coupled<\/a> object dependencies.<\/p>\n<p>In this tutorial, we\u2019ll take a look at a relatively new feature of Mockito that lets us generate mocks on constructor invocations.<\/p>\n<p>To learn more about testing with Mockito, check out our comprehensive <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/tag\/mockito\/\"  rel=\"noopener\">Mockito series<\/a>.<\/p>\n<h2 id=\"bd-dependencies\" data-id=\"dependencies\"><strong>2. Dependencies<\/strong><\/h2>\n<div class=\"bd-anchor\" id=\"dependencies\"><\/div>\n<p>First, we\u2019ll need to add the <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/mvnrepository.com\/artifact\/org.mockito\/mockito-core\"  rel=\"noopener\"><em>mockito<\/em><\/a> dependency to our project:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n    &lt;groupId&gt;org.mockito&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;mockito-core&lt;\/artifactId&gt;\r\n    &lt;version&gt;5.5.0&lt;\/version&gt;\r\n    &lt;scope&gt;test&lt;\/scope&gt;\r\n&lt;\/dependency&gt;\r\n<\/code><\/pre>\n<p>If we&#8217;re using a version of Mockito inferior to version 5, then we&#8217;ll also need to explicitly add Mockito&#8217;s mock maker inline <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/mvnrepository.com\/artifact\/org.mockito\/mockito-inline\"  rel=\"noopener\">dependency<\/a>:<\/p>\n<pre><code class=\"language-xml\">&lt;dependency&gt;\r\n    &lt;groupId&gt;org.mockito&lt;\/groupId&gt;\r\n    &lt;artifactId&gt;mockito-inline&lt;\/artifactId&gt;\r\n    &lt;version&gt;5.2.0&lt;\/version&gt;\r\n    &lt;scope&gt;test&lt;\/scope&gt;\r\n&lt;\/dependency&gt;<\/code><\/pre>\n<h2 id=\"bd-a-quick-word-on-mocking-constructorcalls\" data-id=\"a-quick-word-on-mocking-constructorcalls\">3. A Quick Word on Mocking Constructor\u00a0Calls<\/h2>\n<div class=\"bd-anchor\" id=\"a-quick-word-on-mocking-constructorcalls\"><\/div>\n<p>Generally speaking, some might say that when writing clean object-orientated code, we shouldn\u2019t need to return a mock instance when creating an object. This could typically hint at a design issue or code smell in our application.<\/p>\n<p>Why? First, a class depending on several concrete implementations could be tightly coupled, and second, this nearly always leads to code that is difficult to test. Ideally, a class should not be responsible for obtaining its dependencies, and if possible, they should be externally injected.<\/p>\n<p>So, it\u2019s always worth investigating if we can refactor our code to make it more testable. <strong>Of course, this isn&#8217;t always possible, and sometimes, we need to temporarily replace the behavior of a class after constructing it<\/strong>.<\/p>\n<p>This might be particularly useful in several situations:<\/p>\n<ul>\n<li>Testing difficult-to-reach scenarios &#8211; particularly if our class under test has a complex object hierarchy<\/li>\n<li>Testing interactions with external libraries or frameworks<\/li>\n<li>Working with legacy code<\/li>\n<\/ul>\n<p>In the following sections, <strong>we&#8217;ll see how we can use Mockito&#8217;s <em>MockConstruction<\/em> to combat some of these situations in order to control the creation of objects and specify how they should behave when constructed<\/strong>.<\/p>\n<h2 id=\"bd-mocking-constructors\" data-id=\"mocking-constructors\">4. Mocking Constructors<\/h2>\n<div class=\"bd-anchor\" id=\"mocking-constructors\"><\/div>\n<p>Let&#8217;s start by creating a simple <em>Fruit<\/em> class, which will be the focus of our first unit test:<\/p>\n<pre><code class=\"language-java\">public class Fruit {\r\n    public String getName() {\r\n        return &quot;Apple&quot;;\r\n    }\r\n    public String getColour() {\r\n        return &quot;Red&quot;;\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>Now let&#8217;s go ahead and write our test where we mock the constructor call made to our <em>Fruit<\/em> class:<\/p>\n<pre><code class=\"language-java\">@Test\r\nvoid givenMockedContructor_whenFruitCreated_thenMockIsReturned() {\r\n    assertEquals(&quot;Apple&quot;, new Fruit().getName());\r\n    assertEquals(&quot;Red&quot;, new Fruit().getColour());\r\n    try (MockedConstruction&lt;Fruit&gt; mock = mockConstruction(Fruit.class)) {\r\n        Fruit fruit = new Fruit();\r\n        when(fruit.getName()).thenReturn(&quot;Banana&quot;);\r\n        when(fruit.getColour()).thenReturn(&quot;Yellow&quot;);\r\n        assertEquals(&quot;Banana&quot;, fruit.getName());\r\n        assertEquals(&quot;Yellow&quot;, fruit.getColour());\r\n        List&lt;Fruit&gt; constructed = mock.constructed();\r\n        assertEquals(1, constructed.size());\r\n    }\r\n}<\/code><\/pre>\n<p>In our example, we start by checking that a real <em>Fruit<\/em> object returns the desired values.<\/p>\n<p>Now, to make mocking object constructions possible, we&#8217;ll use the <em>Mockito.mockConstruction()<\/em> method. <strong>This method takes a non-abstract Java class for the constructions we&#8217;re about to mock. In this case, a <em>Fruit<\/em> class.<\/strong><\/p>\n<p>We define this within a <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/java-try-with-resources\"  rel=\"noopener\">try-with-resources<\/a> block. This means that when our code calls the constructor of a <em>Fruit<\/em> object inside the try statement, it returns a mock object. <strong>We should note that the constructor won&#8217;t be mocked by Mockito outside our scoped block.<\/strong><\/p>\n<p>This is a particularly nice feature since it ensures that our mock remains temporary. As we know, if we\u2019re playing around with mock constructor calls during our test runs, this could likely lead to adverse effects on our test results due to the concurrent and sequential nature of running tests.<\/p>\n<h2 id=\"bd-mocking-constructors-inside-another-class\" data-id=\"mocking-constructors-inside-another-class\">5. Mocking Constructors Inside Another Class<\/h2>\n<div class=\"bd-anchor\" id=\"mocking-constructors-inside-another-class\"><\/div>\n<p>A more realistic scenario is when we have a class under test, which creates some objects inside that we would like to mock.<\/p>\n<p>Typically, inside the constructor of our class under test, we might create instances of new objects that we would like to mock from our tests. In this example, we&#8217;ll see how we can do this.<\/p>\n<p>Let&#8217;s start by defining a simple coffee-making application:<\/p>\n<pre><code class=\"language-java\">public class CoffeeMachine {\r\n    private Grinder grinder;\r\n    private WaterTank tank;\r\n    public CoffeeMachine() {\r\n        this.grinder = new Grinder();\r\n        this.tank = new WaterTank();\r\n    }\r\n    public String makeCoffee() {\r\n        String type = this.tank.isEspresso() ? &quot;Espresso&quot; : &quot;Americano&quot;;\r\n        return String.format(&quot;Finished making a delicious %s made with %s beans&quot;, type, this.grinder.getBeans());\r\n    }\r\n}<\/code><\/pre>\n<p>Next, we define the <em>Grinder<\/em> class:<\/p>\n<pre><code class=\"language-java\">public class Grinder {\r\n    private String beans;\r\n    public Grinder() {\r\n        this.beans = &quot;Guatemalan&quot;;\r\n    }\r\n    public String getBeans() {\r\n        return beans;\r\n    }\r\n    public void setBeans(String beans) {\r\n        this.beans = beans;\r\n    }\r\n}<\/code><\/pre>\n<p>Finally, we add the <em>WaterTank<\/em> class:<\/p>\n<pre><code class=\"language-java\">public class WaterTank {\r\n    private int mils;\r\n    public WaterTank() {\r\n        this.mils = 25;\r\n    }\r\n    public boolean isEspresso() {\r\n        return getMils() &lt; 50;\r\n    }\r\n    \r\n    \/\/Getters and Setters\r\n}<\/code><\/pre>\n<p>In this trivial example, our <em>CoffeeMachine<\/em> creates a grinder and tank at construction time. We have one method, <em>makeCoffee(),<\/em> which prints out a message about the brewed coffee.<\/p>\n<p>Now, we can go ahead and write a couple of tests:<\/p>\n<pre><code class=\"language-java\">@Test\r\n void givenNoMockedContructor_whenCoffeeMade_thenRealDependencyReturned() {\r\n    CoffeeMachine machine = new CoffeeMachine();\r\n    assertEquals(&quot;Finished making a delicious Espresso made with Guatemalan beans&quot;, machine.makeCoffee());\r\n}<\/code><\/pre>\n<p>In this first test, we&#8217;re checking that when we don&#8217;t use <em>MockedConstruction,<\/em> our coffee machine returns real dependencies inside.<\/p>\n<p>Now let&#8217;s see how we can return mocks for those dependencies:<\/p>\n<pre><code class=\"language-java\">@Test\r\nvoid givenMockedContructor_whenCoffeeMade_thenMockDependencyReturned() {\r\n    try (MockedConstruction&lt;WaterTank&gt; mockTank = mockConstruction(WaterTank.class); \r\n      MockedConstruction&lt;Grinder&gt; mockGrinder = mockConstruction(Grinder.class)) {\r\n        CoffeeMachine machine = new CoffeeMachine();\r\n        WaterTank tank = mockTank.constructed().get(0);\r\n        Grinder grinder = mockGrinder.constructed().get(0);\r\n        when(tank.isEspresso()).thenReturn(false);\r\n        when(grinder.getBeans()).thenReturn(&quot;Peruvian&quot;);\r\n        assertEquals(&quot;Finished making a delicious Americano made with Peruvian beans&quot;, machine.makeCoffee());\r\n    }\r\n}<\/code><\/pre>\n<p><strong>In this test, we use <em>mockConstruction<\/em> to return mocks instances when we call the constructors of\u00a0 <em>Grinder<\/em> and <em>WaterTank<\/em><\/strong>. Then, we specify the expectations of these mocks using standard <em>when<\/em> notation.<\/p>\n<p>This time around, when we run our test, Mockito ensures that the constructors of <em>Grinder<\/em> and <em>WaterTank<\/em> return the mocked instances with the specified behavior, allowing us to test the <em>makeCoffee<\/em> method in isolation.<\/p>\n<h2 id=\"bd-dealing-with-constructor-arguments\" data-id=\"dealing-with-constructor-arguments\">6. Dealing with Constructor Arguments<\/h2>\n<div class=\"bd-anchor\" id=\"dealing-with-constructor-arguments\"><\/div>\n<p>Another common use case is to be able to deal with a constructor which takes an argument.<\/p>\n<p>Thankfully, <em>mockedConstruction<\/em> provides a mechanism allowing us to access the arguments passed to the constructor:<\/p>\n<p>Let&#8217;s add a new constructor to our <em>WaterTank<\/em>:<\/p>\n<pre><code class=\"language-java\">public WaterTank(int mils) {\r\n    this.mils = mils;\r\n}<\/code><\/pre>\n<p>Likewise, let&#8217;s also add a new constructor to our Coffee application:<\/p>\n<pre><code class=\"language-java\">public CoffeeMachine(int mils) {\r\n    this.grinder = new Grinder();\r\n    this.tank = new WaterTank(mils);\r\n}<\/code><\/pre>\n<p>Finally, we can add another test:<\/p>\n<pre><code class=\"language-java\">@Test\r\nvoid givenMockedContructorWithArgument_whenCoffeeMade_thenMockDependencyReturned() {\r\n    try (MockedConstruction&lt;WaterTank&gt; mockTank = mockConstruction(WaterTank.class, \r\n      (mock, context) -&gt; {\r\n          int mils = (int) context.arguments().get(0);\r\n          when(mock.getMils()).thenReturn(mils);\r\n      }); \r\n      MockedConstruction&lt;Grinder&gt; mockGrinder = mockConstruction(Grinder.class)) {\r\n          CoffeeMachine machine = new CoffeeMachine(100);\r\n          Grinder grinder = mockGrinder.constructed().get(0);\r\n          when(grinder.getBeans()).thenReturn(&quot;Kenyan&quot;);\r\n          assertEquals(&quot;Finished making a delicious Americano made with Kenyan beans&quot;, machine.makeCoffee());\r\n        }\r\n    }<\/code><\/pre>\n<p>This time around, we use a lambda expression to handle the <em>WaterTank<\/em> constructor with arguments. <strong>The lambda receives the mock instance and the construction context, allowing us to access the arguments passed to the constructor.<\/strong><\/p>\n<p>We can then use these arguments to set up the desired behavior for the <em>getMils<\/em> method.<\/p>\n<h2 id=\"bd-changing-the-default-mocking-behaviour\" data-id=\"changing-the-default-mocking-behaviour\">7. Changing the Default Mocking Behaviour<\/h2>\n<div class=\"bd-anchor\" id=\"changing-the-default-mocking-behaviour\"><\/div>\n<p>It&#8217;s important to note that for methods, we don&#8217;t stub a mock return null by default. <strong>We can take our Fruit example one step further and let the mock behave like a real <em>Fruit<\/em> instance:<\/strong><\/p>\n<pre><code class=\"language-java\">@Test\r\nvoid givenMockedContructorWithNewDefaultAnswer_whenFruitCreated_thenRealMethodInvoked() {\r\n    try (MockedConstruction&lt;Fruit&gt; mock = mockConstruction(Fruit.class, withSettings().defaultAnswer(Answers.CALLS_REAL_METHODS))) {\r\n        Fruit fruit = new Fruit();\r\n        assertEquals(&quot;Apple&quot;, fruit.getName());\r\n        assertEquals(&quot;Red&quot;, fruit.getColour());\r\n    }\r\n}<\/code><\/pre>\n<p>This time, we pass an extra parameter <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/www.baeldung.com\/mockito-mocksettings\"><em>MockSettings<\/em><\/a> to the <em>mockConstruction <\/em>method to tell it to create a mock that will behave like a real <em>Fruit<\/em> instance for methods that we didn&#8217;t stub.<\/p>\n<h2 id=\"bd-conclusion\" data-id=\"conclusion\">8. Conclusion<\/h2>\n<div class=\"bd-anchor\" id=\"conclusion\"><\/div>\n<p>In this quick article, we\u2019ve seen a couple of examples of how we can use Mockito to mock constructor calls. To summarise, Mockito provides a graceful solution to generate mocks on constructor invocations within the current thread and a user-defined scope.<\/p>\n<p>As always, the full source code of the article is available <a href=\"https:\/\/feeds.feedblitz.com\/~\/t\/0\/0\/baeldung\/~https:\/\/github.com\/eugenp\/tutorials\/tree\/master\/testing-modules\/mockito-2\"  rel=\"noopener\">over on GitHub<\/a>.<\/p>\n<p><Img align=\"left\" border=\"0\" height=\"1\" width=\"1\" alt=\"\" style=\"border:0;float:left;margin:0;padding:0;width:1px!important;height:1px!important;\" hspace=\"0\" src=\"https:\/\/feeds.feedblitz.com\/~\/i\/796551905\/0\/baeldung\"><\/p>\n<div style=\"clear:both;padding-top:0.2em;\"><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/796551905\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/796551905\/baeldung,https%3A%2F%2Fwww.baeldung.com%2Fwp-content%2Fuploads%2F2021%2F01%2FOn-Baeldung-7-1024x536.jpg\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/796551905\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/796551905\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/796551905\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\" style=\"border:0;margin:0;padding:0;\"><\/a>&#160;<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/java-mockito-mockedconstruction#respond\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>&#160;<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/java-mockito-mockedconstruction\/feed\"><img decoding=\"async\" height=\"20\" style=\"border:0;margin:0;padding:0;\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>&#160;<\/div>\n\n<h2><b>Commercials Cooperation Advertisements:<\/b><\/h2>\r\n<p><br>(1) IT Teacher IT Freelance<br> <\/p>\r\n<a href=https:\/\/itteacheritfreelance.hk\/wordpress><img src=http:\/\/gamefootballmobileanimeiphone.com\/wp-content\/uploads\/2023\/09\/ITTeacherITFreelance-Website.png alt=IT\u96fb\u8166\u88dc\u7fd2 java\u88dc\u7fd2 \u70ba\u5927\u5bb6\u914d\u5c0d\u96fb\u8166\u88dc\u7fd2,IT freelance, \u79c1\u4eba\u8001\u5e2b, PHP\u88dc\u7fd2,CSS\u88dc\u7fd2,XML,Java\u88dc\u7fd2,MySQL\u88dc\u7fd2,graphic design\u88dc\u7fd2,\u4e2d\u5c0f\u5b78ICT\u88dc\u7fd2,\u4e00\u5c0d\u4e00\u79c1\u4eba\u88dc\u7fd2\u548cFreelance\u81ea\u7531\u5de5\u4f5c\u914d\u5c0d\u3002\/><\/a><p><a href=https:\/\/itteacheritfreelance.hk\/wordpress\/index.php\/findteacher>\u7acb\u523b\u8a3b\u518a\u53ca\u5831\u540d\u96fb\u8166\u88dc\u7fd2\u8ab2\u7a0b\u5427! <\/a><br>\r\n\r\n\u7535\u5b50\u8ba1\u7b97\u673a -\u6559\u80b2 -IT \u96fb\u8166\u73ed\u201d ( IT\u96fb\u8166\u88dc\u7fd2 ) \u63d0\u4f9b\u4e00\u500b\u65b9\u4fbf\u7684\u7535\u5b50\u8ba1\u7b97\u673a \u6559\u80b2\u5e73\u53f0, \u70ba\u5927\u5bb6\u914d\u5c0d\u4fe1\u606f\u6280\u672f, \u96fb\u8166 \u8001\u5e2b, IT freelance \u548c programming expert. \u8b93\u5927\u5bb6\u65b9\u4fbf\u5730\u5c31\u80fd\u627e\u5230\u5408\u9069\u7684\u96fb\u8166\u88dc\u7fd2, \u96fb\u8166\u73ed, \u5bb6\u6559, \u79c1\u4eba\u8001\u5e2b.  <br>\r\n\r\nWe are a education and information platform which you can find a IT private tutorial teacher or freelance. <br>\r\n\r\nAlso we provide different information about information technology, Computer, programming, mobile, Android, apple, game, movie, anime, animation\u2026 \r\n<\/p>\n<p><br>(2) ITSec<br> <\/p><a href=https:\/\/itsec.vip><img src=http:\/\/gamefootballmobileanimeiphone.com\/wp-content\/uploads\/2023\/09\/ITSec-Main-Promotion-Image.png alt= https:\/\/itsec.vip\/\r\nSecure Your Computers from Cyber Threats and mitigate risks with professional services to defend Hackers.  \r\nITSec provide IT Security and Compliance Services, including IT Compliance Services, Risk Assessment, IT Audit, Security Assessment and Audit, ISO 27001 Consulting and Certification, GDPR Compliance Services, Privacy Impact Assessment (PIA), Penetration test, Ethical Hacking, Vulnerabilities scan, IT Consulting, Data Privacy Consulting, Data Protection Services, Information Security Consulting, Cyber Security Consulting, Network Security Audit, Security Awareness Training.\/><\/a> \r\n<br><br> \r\n<p><a href=https:\/\/itsec.vip>www.ITSec.vip<\/a> <br> <br> \r\n<p><a href=https:\/\/sraa.com.hk>www.Sraa.com.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/itsec.hk>www.ITSec.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/penetrationtest.hk>www.Penetrationtest.hk<\/a> <br> <br> \r\n<p><a href=https:\/\/itseceu.uk>www.ITSeceu.uk<\/a> <br> <br> \r\nSecure Your Computers from Cyber Threats and mitigate risks with professional services to defend Hackers. <br><br>\r\nITSec provide IT Security and Compliance Services, including IT Compliance Services, Risk Assessment, IT Audit, Security Assessment and Audit, ISO 27001 Consulting and Certification, GDPR Compliance Services, Privacy Impact Assessment (PIA), Penetration test, Ethical Hacking, Vulnerabilities scan, IT Consulting, Data Privacy Consulting, Data Protection Services, Information Security Consulting, Cyber Security Consulting, Network Security Audit, Security Awareness Training. \r\n<br><br>Contact us right away. <br><br>Email (Prefer using email to contact us): <br>SalesExecutive@ITSec.vip<\/p>","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/www.baeldung.com\/wp-content\/uploads\/2021\/01\/On-Baeldung-7-1024x536.jpg\" class=\"webfeedsFeaturedVisual wp-post-image\" alt=\"\"><\/p>\n<p>A quick and practical guide to Mockito&#8217;s MockedConstruction.<\/p>\n<div><a title=\"Like on Facebook\" href=\"https:\/\/feeds.feedblitz.com\/_\/28\/796551905\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/fblike20.png\"><\/a>\u00a0<a title=\"Pin it!\" href=\"https:\/\/feeds.feedblitz.com\/_\/29\/796551905\/baeldung,https%3A%2F%2Fwww.baeldung.com%2Fwp-content%2Fuploads%2F2021%2F01%2FOn-Baeldung-7-1024x536.jpg\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/pinterest20.png\"><\/a>\u00a0<a title=\"Tweet This\" href=\"https:\/\/feeds.feedblitz.com\/_\/24\/796551905\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/twitter20.png\"><\/a>\u00a0<a title=\"Subscribe by email\" href=\"https:\/\/feeds.feedblitz.com\/_\/19\/796551905\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/email20.png\"><\/a>\u00a0<a title=\"Subscribe by RSS\" href=\"https:\/\/feeds.feedblitz.com\/_\/20\/796551905\/baeldung\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/rss20.png\"><\/a>\u00a0<a rel=\"NOFOLLOW\" title=\"View Comments\" href=\"https:\/\/www.baeldung.com\/java-mockito-mockedconstruction#respond\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/comments20.png\"><\/a>\u00a0<a title=\"Follow Comments via RSS\" href=\"https:\/\/www.baeldung.com\/java-mockito-mockedconstruction\/feed\"><img decoding=\"async\" height=\"20\" src=\"https:\/\/assets.feedblitz.com\/i\/commentsrss20.png\"><\/a>\u00a0<\/div>\n","protected":false},"author":254,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[22],"tags":[61,122,127,129,124,128,125,132,131,133,126,130,123,66,94,88,97,56,64,65,60,112,40,75,95,104,33,120,105,101,98,115,30,29,41,86,70,69,68,72,71,26,118,108,87,46,55,48,52,54,51,50,83,62,58,57,109,35,59,63,85,79,82,96,80,27,81,114,44,42,43,45,38,39,2469,110,117,100,111,116,73,89,90,92,91,93,84,78,37,102,34,36,77,67,74,99,113,119,28,2468,121,32,47,49,53,103,31,76],"class_list":["post-5409","post","type-post","status-publish","format-standard","hentry","category-mobile","tag-airpods","tag-anime","tag-anime-characters","tag-anime-cosplay","tag-anime-edits","tag-anime-merchandise","tag-anime-movies","tag-anime-news","tag-anime-recommendations","tag-anime-reviews","tag-anime-series","tag-anime-streaming","tag-animes","tag-app-store","tag-app-store-samsung","tag-appgallery","tag-appgallery-oneplus","tag-apple","tag-apple-music","tag-apple-tv","tag-apple-watch","tag-bbc-sport","tag-best-mobile-games","tag-bixby","tag-bixby-xiaomi","tag-champions-league","tag-cyberpunk","tag-cyberpunk-2077","tag-fantasy-football","tag-fifa","tag-football","tag-formula-1","tag-fortnite","tag-free-fire","tag-free-mobile-games","tag-freebuds-pro","tag-galaxy-a52","tag-galaxy-note-20","tag-galaxy-s21","tag-galaxy-watch-4","tag-galaxy-z-fold-3","tag-game","tag-games","tag-golf","tag-harmonyos","tag-how-to-backup-iphone","tag-how-to-factory-reset-iphone","tag-how-to-reset-iphone","tag-how-to-restore-iphone","tag-how-to-unlock-iphone","tag-how-to-unlock-iphone-5","tag-how-to-unlock-iphone-6","tag-huawei","tag-ios","tag-ipad","tag-iphone","tag-live-soccer","tag-lol","tag-macbook","tag-macos","tag-mate-40-pro","tag-mi-11-lite","tag-mi-home-security-camera-basic-1080p","tag-mi-home-security-camera-basic-1080p-huawei","tag-mi-smart-band-6","tag-minecraft","tag-miui","tag-mlb-scores","tag-mobile-game-design","tag-mobile-game-development","tag-mobile-game-marketing","tag-mobile-game-monetization","tag-mobile-games","tag-mobile-gaming","tag-mockito","tag-nba-scores","tag-nba-standings","tag-nfl","tag-nfl-scores","tag-nhl-scores","tag-one-ui","tag-oneplus","tag-oneplus-9-pro","tag-oneplus-buds-pro","tag-oneplus-nord-ce-5g","tag-oxygenos","tag-p40-pro-plus","tag-poco-x3-pro","tag-pokemon","tag-premier-league","tag-pubg","tag-pubg-mobile","tag-redmi-note-10-pro","tag-samsung","tag-samsung-pay","tag-soccer","tag-sports","tag-steam","tag-steeam","tag-testing","tag-top-10-anime","tag-valorant","tag-when-do-the-iphone-7-come-out","tag-when-does-the-iphone-7-come-out","tag-when-is-the-iphone-7-coming-out","tag-world-cup","tag-xbox-series-x","tag-xiaomi"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/5409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/users\/254"}],"replies":[{"embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/comments?post=5409"}],"version-history":[{"count":3,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/5409\/revisions"}],"predecessor-version":[{"id":5695,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/posts\/5409\/revisions\/5695"}],"wp:attachment":[{"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/media?parent=5409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/categories?post=5409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gamefootballmobileanimeiphone.com\/index.php\/wp-json\/wp\/v2\/tags?post=5409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}