{"id":21697,"date":"2015-03-26T15:00:52","date_gmt":"2015-03-26T13:00:52","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=21697"},"modified":"2022-09-27T15:20:58","modified_gmt":"2022-09-27T12:20:58","slug":"mockito-verify-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/","title":{"rendered":"Mockito Verify Example"},"content":{"rendered":"<p>In this article, I am going to show you an example of Mockito Verify. To test the state, we use <code>assert<\/code>, likewise, to verify the test interactions, we use <code>Mockito.verify<\/code>.<\/p>\n<p>Below are my&nbsp;setup details:<\/p>\n<ul>\n<li>I am using&nbsp;<a class=\"ext-link\" title=\"\" href=\"http:\/\/maven.apache.org\/\" rel=\"external nofollow\">Maven<\/a>&nbsp;\u2013 the&nbsp;build tool<\/li>\n<li><a class=\"ext-link\" title=\"\" href=\"http:\/\/www.eclipse.org\/\" rel=\"external nofollow\">Eclipse <\/a>&nbsp;as the&nbsp;IDE, version Luna 4.4.1.<\/li>\n<li><a class=\"ext-link\" title=\"\" href=\"http:\/\/testng.org\/doc\/index.html\" rel=\"external nofollow\">TestNG <\/a>&nbsp;is my&nbsp;testing framework, in case you are new to TestNG, please refer&nbsp;<a href=\"http:\/\/examples.javacodegeeks.com\/enterprise-java\/testng\/testng-maven-project-example\/\">TestNG Maven Project Example.<\/a><\/li>\n<li>Add <a class=\"ext-link\" title=\"\" href=\"https:\/\/maven-badges.herokuapp.com\/maven-central\/org.mockito\/mockito-core\" rel=\"external nofollow\">Mockito dependency<\/a> to our <code>pom.xml<\/code>.<\/li>\n<\/ul>\n<p>Let&#8217;s start verifying behavior!\n<\/p>\n<h2>1. System Under Test (SUT)<\/h2>\n<p>A test consists of the following three steps:<\/p>\n<ol>\n<li>Stubbing<\/li>\n<li>Running the SUT<\/li>\n<li>Verifying the behavior of SUT<\/li>\n<\/ol>\n<p>In this example, the system under test is a <code>Customer<\/code> who wants to withdraw some money. It has method <code>withdraw(amount)<\/code> which collaborates with an <code>AccountManager<\/code> to validate whether the customer has enough funds to withdraw.<\/p>\n<p>If the customer has enough funds, the account manager will allow withdrawing money and return us the new balance. If the&nbsp;funds are not enough, it will throw <code>NotEnoughFundsException<\/code>.<\/p>\n<p>Ok, we know our&nbsp;SUT, we need to know the class we are going to stub. Well&#8230;can you make a guess?&nbsp;It is <code>AccountManager<\/code>. In this example, we will stub its methods and verify how our SUT behaves in each case.<\/p>\n<p>Before we start with our test cases, let&#8217;s go through each class.<\/p>\n<p>The first one is an <code>Account<\/code> class. It is empty, as the actual processing is handled only in <code>AccountManager<\/code><\/p>\n<p><span style=\"text-decoration: underline;\"><em>Account:<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.mockito;\n\npublic class Account {\n}\n<\/pre>\n<p>Next is <code>Customer<\/code> class. We already know its behavior but I just thought of adding couple of more points here:<\/p>\n<ol>\n<li><code>Customer<\/code> relies on <code>AccountManager<\/code> for withdrawing the amount. It has method <code>setAccountManager(AccountManager)<\/code> which we will use to set the mock object<\/li>\n<li><code>withdraw(amount)<\/code> throws <code>NotEnoughFundsException<\/code> if funds are not enough. Else it will return the new balance after the withdrawal process.<\/li>\n<\/ol>\n<p><span style=\"text-decoration: underline;\"><em>Customer:<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.mockito;\n\npublic class Customer {\n\tprivate AccountManager accountManager;\n\n\tpublic long withdraw(long amount) throws NotEnoughFundsException {\n\t\tAccount account = accountManager.findAccount(this);\n\t\tlong balance = accountManager.getBalance(account);\n\t\tif (balance &lt; amount) {\n\t\t\tthrow new NotEnoughFundsException();\n\t\t}\n\t\taccountManager.withdraw(account, amount);\n\t\treturn accountManager.getBalance(account);\n\t}\n\n\tpublic void setAccountManager(AccountManager accountManager) {\n\t\tthis.accountManager = accountManager;\n\t}\n}\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>NotEnoughFundsException:<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.mockito;\n\npublic class NotEnoughFundsException extends Exception {\n\tprivate static final long serialVersionUID = 1L;\n}\n<\/pre>\n<p><code>AccountManager<\/code> is responsible for managing the funds. Its methods are self-explanatory.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>AccountManager:<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.mockito;\n\npublic interface AccountManager {\n\n\tlong getBalance(Account account);\n\n\tlong withdraw(Account account, long amount);\n\n\tAccount findAccount(Customer customer);\n\n}\n<\/pre>\n<h2>2. Verify Behavior<\/h2>\n<p>The first test case is <code>withdrawButNotEnoughFunds<\/code>. We will try to withdraw more amount than is allowed. In the <code>@BeforeMethod<\/code> called <code>setupMock()<\/code>, we create the <code>Customer<\/code> object, mock <code>AccountManager<\/code> and set it to the <code>Customer<\/code>. We stub the <code>accountManager.findAccount(customer)<\/code> to return <code>Account<\/code> object.<\/p>\n<p>Few points to note about the test case:<\/p>\n<ol>\n<li>Stub <code>AccountManager<\/code> to return balance lesser than the amount requested.\n<pre class=\"brush:java\">when(accountManager.getBalance(account)).thenReturn(balanceAmount200);<\/pre>\n<\/li>\n<li>Run the SUT method <code>Customer.withdraw(2000)<\/code><\/li>\n<li>Assert using <code>expectedExceptions<\/code> attribute that <code>NotEnoughFundsException<\/code> is thrown<\/li>\n<li>Verify that certain methods from the mock object are called.<\/li>\n<li>Verify that <code>accountManager.findAccount(customer)<\/code> was called.\n<pre class=\"brush:java\">verify(accountManager).findAccount(customer)<\/pre>\n<\/li>\n<li>Verify that <code>accountManager.withdraw(account, amount)<\/code> was never called.\n<pre class=\"brush:java\">verify(accountManager, times(0)).withdraw(account, withdrawlAmount2000);<\/pre>\n<\/li>\n<\/ol>\n<p><span style=\"text-decoration: underline;\"><em>MockitoVerifyExample:<\/em><\/span><\/p>\n<pre class=\"brush:java\">package com.javacodegeeks.mockito;\n\nimport static org.mockito.Mockito.*;\n\nimport org.mockito.InOrder;\nimport org.testng.annotations.BeforeMethod;\nimport org.testng.annotations.Test;\n\npublic class MockitoVerifyExample {\n\tprivate Customer customer;\n\tprivate AccountManager accountManager;\n\tprivate Account account;\n\tprivate long withdrawlAmount2000 = 2000L;\n\t\n\t@BeforeMethod\n\tpublic void setupMock() {\n\t\tcustomer = new Customer();\n\t\taccountManager = mock(AccountManager.class);\n\t\tcustomer.setAccountManager(accountManager);\n\t\taccount = mock(Account.class);\n\t\twhen(accountManager.findAccount(customer)).thenReturn(account);\t\t\n\t}\n\t\n\t@Test(expectedExceptions=NotEnoughFundsException.class)\n\tpublic void withdrawButNotEnoughFunds() throws NotEnoughFundsException {\n\t\tlong balanceAmount200 = 200L;\n\t\t\n\t\tp(\"Train getBalance(account) to return \" + balanceAmount200);\n\t\twhen(accountManager.getBalance(account)).thenReturn(balanceAmount200);\n\t\t\n\t\tprintBalance(balanceAmount200);\n\t\ttry {\n\t\t\tp(\"Customer.withdraw(\" + withdrawlAmount2000 + \") should fail with NotEnoughFundsException\");\n\t\t\tcustomer.withdraw(withdrawlAmount2000);\t\t\t\n\t\t} catch (NotEnoughFundsException e) {\n\t\t\tp(\"NotEnoughFundsException is thrown\"); \n\t\t\t\n\t\t\tverify(accountManager).findAccount(customer);\n\t\t\tp(\"Verified findAccount(customer) is called\");\t\t\t\n\t\t\t\n\t\t\tverify(accountManager, times(0)).withdraw(account, withdrawlAmount2000);\n\t\t\tp(\"Verified withdraw(account, \" + withdrawlAmount2000 + \") is not called\");\n\t\t\t\n\t\t\tthrow e;\n\t\t}\n\t}\n\n\tprivate static void p(String text) {\n\t\tSystem.out.println(text);\n\t}\n\t\n\tprivate void printBalance(long balance) {\n\t\tp(\"Balance is \" + balance + \" and withdrawl amount \" + withdrawlAmount2000);\t\n\t}\n}\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>Output:<\/em><\/span><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:bash\">Train getBalance(account) to return 200\nBalance is 200 and withdrawl amount 2000\nCustomer.withdraw(2000) should fail with NotEnoughFundsException\nNotEnoughFundsException is thrown\nVerified findAccount(customer) is called\nVerified withdraw(account, 2000) is not called\nPASSED: withdrawButNotEnoughFunds\n<\/pre>\n<h2>3. Verification by count<\/h2>\n<p>In the next example of Mockito Verify, we will review the test case <code>withdrawal()<\/code> which defines the success scenario. Few points to note about the test case:<\/p>\n<ol>\n<li>We stub <code>accountManager.getBalance(customer)<\/code> to return enough balance for a successful withdrawal.<\/li>\n<li>Since withdrawal was successful, we verify that <code>accountManager.withdraw(account, amount)<\/code> was called.\n<pre class=\"brush:xml\">verify(accountManager).withdraw(account, withdrawlAmount2000);\n<\/pre>\n<\/li>\n<li>We also verify the number of times a method was called. For example, in the case of successful withdrawal, we end up calling <code>accountManager.getBalance(account)<\/code> twice. Once before the withdrawal and the second time after the withdrawal.\n<pre class=\"brush:java\">verify(accountManager, times(2)).getBalance(account)<\/pre>\n<\/li>\n<li>Account is determined only once.\n<pre class=\"brush:java\">verify(accountManager, atLeastOnce()).findAccount(customer);<\/pre>\n<\/li>\n<\/ol>\n<p><span style=\"text-decoration: underline;\"><em>MockitoVerifyExample:<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight:[48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71]\">package com.javacodegeeks.mockito;\n\nimport static org.mockito.Mockito.*;\n\nimport org.mockito.InOrder;\nimport org.testng.annotations.BeforeMethod;\nimport org.testng.annotations.Test;\n\npublic class MockitoVerifyExample {\n\tprivate Customer customer;\n\tprivate AccountManager accountManager;\n\tprivate Account account;\n\tprivate long withdrawlAmount2000 = 2000L;\n\t\n\t@BeforeMethod\n\tpublic void setupMock() {\n\t\tcustomer = new Customer();\n\t\taccountManager = mock(AccountManager.class);\n\t\tcustomer.setAccountManager(accountManager);\n\t\taccount = mock(Account.class);\n\t\twhen(accountManager.findAccount(customer)).thenReturn(account);\t\t\n\t}\n\t\n\t@Test(expectedExceptions=NotEnoughFundsException.class)\n\tpublic void withdrawButNotEnoughFunds() throws NotEnoughFundsException {\n\t\tlong balanceAmount200 = 200L;\n\t\t\n\t\tp(\"Train getBalance(account) to return \" + balanceAmount200);\n\t\twhen(accountManager.getBalance(account)).thenReturn(balanceAmount200);\n\t\t\n\t\tprintBalance(balanceAmount200);\n\t\ttry {\n\t\t\tp(\"Customer.withdraw(\" + withdrawlAmount2000 + \") should fail with NotEnoughFundsException\");\n\t\t\tcustomer.withdraw(withdrawlAmount2000);\t\t\t\n\t\t} catch (NotEnoughFundsException e) {\n\t\t\tp(\"NotEnoughFundsException is thrown\"); \n\t\t\t\n\t\t\tverify(accountManager).findAccount(customer);\n\t\t\tp(\"Verified findAccount(customer) is called\");\t\t\t\n\t\t\t\n\t\t\tverify(accountManager, times(0)).withdraw(account, withdrawlAmount2000);\n\t\t\tp(\"Verified withdraw(account, \" + withdrawlAmount2000 + \") is not called\");\n\t\t\t\n\t\t\tthrow e;\n\t\t}\n\t}\n\t\n\t@Test\n\tpublic void withdraw() throws NotEnoughFundsException {\t\t\n\t\tlong balanceAmount3000 = 3000L;\n\t\t\n\t\tp(\"Train getBalance(account) to return \" + balanceAmount3000);\n\t\twhen(accountManager.getBalance(account)).thenReturn(balanceAmount3000);\n\t\t\n\t\tprintBalance(balanceAmount3000);\n\t\t\n\t\tp(\"Customer.withdraw(\" + withdrawlAmount2000 + \")\");\n\t\tcustomer.withdraw(withdrawlAmount2000);\n\t\t\n\t\tverify(accountManager, times(2)).getBalance(account);\n\t\tp(\"Verified getBalance(account) is called twice\");\n\t\t\n\t\tverify(accountManager).withdraw(account, withdrawlAmount2000);\n\t\tp(\"Verified withdraw(account, \" +  withdrawlAmount2000 + \") is called just once\");\n\t\t\n\t\tverify(accountManager, atLeastOnce()).findAccount(customer);\n\t\tp(\"Verified findAccount(account) is called atleast once\");\n\t}\n\n\tprivate static void p(String text) {\n\t\tSystem.out.println(text);\n\t}\n\t\n\tprivate void printBalance(long balance) {\n\t\tp(\"Balance is \" + balance + \" and withdrawl amount \" + withdrawlAmount2000);\t\n\t}\t\n}\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>Output:<\/em><\/span><\/p>\n<pre class=\"brush:bash\">Train getBalance(account) to return 3000\nBalance is 3000 and withdrawl amount 2000\nCustomer.withdraw(2000)\nVerified getBalance(account) is called twice\nVerified withdraw(account, 2000) is called just once\nVerified findAccount(account) is called atleast once\nPASSED: withdraw\n<\/pre>\n<h2>4. Verify Order<\/h2>\n<p>In our next test case <code>withdrawAndVerifyOrder<\/code>, we verify the order in which methods were called using <code>inOrder()<\/code>. To enforce the order verification, we need to call our <code>verify()<\/code> methods on the <code>InOrder<\/code> object.<\/p>\n<pre class=\":brush:java\">order.verify(accountManager).findAccount(customer);\n<\/pre>\n<pre class=\"brush:java\">InOrder order = inOrder(accountManager);<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>MockitoVerifyExample:<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight:[73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99]\">package com.javacodegeeks.mockito;\n\nimport static org.mockito.Mockito.*;\n\nimport org.mockito.InOrder;\nimport org.testng.annotations.BeforeMethod;\nimport org.testng.annotations.Test;\n\npublic class MockitoVerifyExample {\n\tprivate Customer customer;\n\tprivate AccountManager accountManager;\n\tprivate Account account;\n\tprivate long withdrawlAmount2000 = 2000L;\n\t\n\t@BeforeMethod\n\tpublic void setupMock() {\n\t\tcustomer = new Customer();\n\t\taccountManager = mock(AccountManager.class);\n\t\tcustomer.setAccountManager(accountManager);\n\t\taccount = mock(Account.class);\n\t\twhen(accountManager.findAccount(customer)).thenReturn(account);\t\t\n\t}\n\t\n\t@Test(expectedExceptions=NotEnoughFundsException.class)\n\tpublic void withdrawButNotEnoughFunds() throws NotEnoughFundsException {\n\t\tlong balanceAmount200 = 200L;\n\t\t\n\t\tp(\"Train getBalance(account) to return \" + balanceAmount200);\n\t\twhen(accountManager.getBalance(account)).thenReturn(balanceAmount200);\n\t\t\n\t\tprintBalance(balanceAmount200);\n\t\ttry {\n\t\t\tp(\"Customer.withdraw(\" + withdrawlAmount2000 + \") should fail with NotEnoughFundsException\");\n\t\t\tcustomer.withdraw(withdrawlAmount2000);\t\t\t\n\t\t} catch (NotEnoughFundsException e) {\n\t\t\tp(\"NotEnoughFundsException is thrown\"); \n\t\t\t\n\t\t\tverify(accountManager).findAccount(customer);\n\t\t\tp(\"Verified findAccount(customer) is called\");\t\t\t\n\t\t\t\n\t\t\tverify(accountManager, times(0)).withdraw(account, withdrawlAmount2000);\n\t\t\tp(\"Verified withdraw(account, \" + withdrawlAmount2000 + \") is not called\");\n\t\t\t\n\t\t\tthrow e;\n\t\t}\n\t}\n\t\n\t@Test\n\tpublic void withdraw() throws NotEnoughFundsException {\t\t\n\t\tlong balanceAmount3000 = 3000L;\n\t\t\n\t\tp(\"Train getBalance(account) to return \" + balanceAmount3000);\n\t\twhen(accountManager.getBalance(account)).thenReturn(balanceAmount3000);\n\t\t\n\t\tprintBalance(balanceAmount3000);\n\t\t\n\t\tp(\"Customer.withdraw(\" + withdrawlAmount2000 + \")\");\n\t\tcustomer.withdraw(withdrawlAmount2000);\n\t\t\n\t\tverify(accountManager).withdraw(account, withdrawlAmount2000);\n\t\tp(\"Verified withdraw(account, \" + withdrawlAmount2000 + \") is Called\");\n\t\t\n\t\tverify(accountManager, times(2)).getBalance(account);\n\t\tp(\"Verified getBalance(account) is called twice\");\n\t\t\n\t\tverify(accountManager).withdraw(account, withdrawlAmount2000);\n\t\tp(\"Verified withdraw(account, \" +  withdrawlAmount2000 + \") is called just once\");\n\t\t\n\t\tverify(accountManager, atLeastOnce()).findAccount(customer);\n\t\tp(\"Verified findAccount(account) is called atleast once\");\n\t}\n\t\n\t@Test\n\tpublic void withdrawAndVerifyOrder() throws NotEnoughFundsException {\t\n\t\tlong balanceAmount3000 = 3000L;\n\t\t\n\t\tp(\"Train getBalance(account) to return \" + balanceAmount3000);\n\t\twhen(accountManager.getBalance(account)).thenReturn(balanceAmount3000);\n\t\t\n\t\tprintBalance(balanceAmount3000);\n\t\t\n\t\tp(\"Customer.withdraw(\" + withdrawlAmount2000 + \")\");\n\t\tcustomer.withdraw(withdrawlAmount2000);\n\t\t\n\t\tp(\"Verify order of method calls\");\n\t\tInOrder order = inOrder(accountManager);\n\t\t\n\t\torder.verify(accountManager).findAccount(customer);\n\t\tp(\"Verified findAccount(account) is called\");\n\t\t\n\t\torder.verify(accountManager).getBalance(account);\n\t\tp(\"Verified getBalance(account) is called\");\n\t\t\n\t\torder.verify(accountManager).withdraw(account, withdrawlAmount2000);\n\t\tp(\"Verified withdraw(account, \" +  withdrawlAmount2000 + \") is called\");\n\t\t\n\t\torder.verify(accountManager).getBalance(account);\n\t\tp(\"Verified getBalance(account) is called one more time after withdrawl\");\n\t}\n\t\n\tprivate static void p(String text) {\n\t\tSystem.out.println(text);\n\t}\n\t\n\tprivate void printBalance(long balance) {\n\t\tp(\"Balance is \" + balance + \" and withdrawl amount \" + withdrawlAmount2000);\t\n\t}\n}\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>Output:<\/em><\/span>[ulp id=&#8217;GhnY46zldrhgoeym&#8217;]<\/p>\n<pre class=\"brush:bash\">Train getBalance(account) to return 3000\nBalance is 3000 and withdrawl amount 2000\nCustomer.withdraw(2000)\nVerify order of method calls\nVerified findAccount(account) is called\nVerified getBalance(account) is called\nVerified withdraw(account, 2000) is called\nVerified getBalance(account) is called one more time after withdrawl\nPASSED: withdrawAndVerifyOrder\n<\/pre>\n<h2>5. Unverified Interaction<\/h2>\n<p>In our last example, we will improve our previous test case <code>withdrawAndVerifyOrder()<\/code>. We will call <code>verifyNoMoreInteractions(accountManager)<\/code> in the end after verifying all the methods to make sure that nothing else was invoked on your mocks.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>MockitoVerifyExample:<\/em><\/span><\/p>\n<pre class=\"brush:java; highlight:[100,101]\">package com.javacodegeeks.mockito;\n\nimport static org.mockito.Mockito.*;\n\nimport org.mockito.InOrder;\nimport org.testng.annotations.BeforeMethod;\nimport org.testng.annotations.Test;\n\npublic class MockitoVerifyExample {\n\tprivate Customer customer;\n\tprivate AccountManager accountManager;\n\tprivate Account account;\n\tprivate long withdrawlAmount2000 = 2000L;\n\t\n\t@BeforeMethod\n\tpublic void setupMock() {\n\t\tcustomer = new Customer();\n\t\taccountManager = mock(AccountManager.class);\n\t\tcustomer.setAccountManager(accountManager);\n\t\taccount = mock(Account.class);\n\t\twhen(accountManager.findAccount(customer)).thenReturn(account);\t\t\n\t}\n\t\n\t@Test(expectedExceptions=NotEnoughFundsException.class)\n\tpublic void withdrawButNotEnoughFunds() throws NotEnoughFundsException {\n\t\tlong balanceAmount200 = 200L;\n\t\t\n\t\tp(\"Train getBalance(account) to return \" + balanceAmount200);\n\t\twhen(accountManager.getBalance(account)).thenReturn(balanceAmount200);\n\t\t\n\t\tprintBalance(balanceAmount200);\n\t\ttry {\n\t\t\tp(\"Customer.withdraw(\" + withdrawlAmount2000 + \") should fail with NotEnoughFundsException\");\n\t\t\tcustomer.withdraw(withdrawlAmount2000);\t\t\t\n\t\t} catch (NotEnoughFundsException e) {\n\t\t\tp(\"NotEnoughFundsException is thrown\"); \n\t\t\t\n\t\t\tverify(accountManager).findAccount(customer);\n\t\t\tp(\"Verified findAccount(customer) is called\");\t\t\t\n\t\t\t\n\t\t\tverify(accountManager, times(0)).withdraw(account, withdrawlAmount2000);\n\t\t\tp(\"Verified withdraw(account, \" + withdrawlAmount2000 + \") is not called\");\n\t\t\t\n\t\t\tthrow e;\n\t\t}\n\t}\n\t\n\t@Test\n\tpublic void withdraw() throws NotEnoughFundsException {\t\t\n\t\tlong balanceAmount3000 = 3000L;\n\t\t\n\t\tp(\"Train getBalance(account) to return \" + balanceAmount3000);\n\t\twhen(accountManager.getBalance(account)).thenReturn(balanceAmount3000);\n\t\t\n\t\tprintBalance(balanceAmount3000);\n\t\t\n\t\tp(\"Customer.withdraw(\" + withdrawlAmount2000 + \")\");\n\t\tcustomer.withdraw(withdrawlAmount2000);\n\t\t\n\t\tverify(accountManager).withdraw(account, withdrawlAmount2000);\n\t\tp(\"Verified withdraw(account, \" + withdrawlAmount2000 + \") is Called\");\n\t\t\n\t\tverify(accountManager, times(2)).getBalance(account);\n\t\tp(\"Verified getBalance(account) is called twice\");\n\t\t\n\t\tverify(accountManager).withdraw(account, withdrawlAmount2000);\n\t\tp(\"Verified withdraw(account, \" +  withdrawlAmount2000 + \") is called just once\");\n\t\t\n\t\tverify(accountManager, atLeastOnce()).findAccount(customer);\n\t\tp(\"Verified findAccount(account) is called atleast once\");\n\t}\n\t\n\t@Test\n\tpublic void withdrawAndVerifyOrder() throws NotEnoughFundsException {\t\n\t\tlong balanceAmount3000 = 3000L;\n\t\t\n\t\tp(\"Train getBalance(account) to return \" + balanceAmount3000);\n\t\twhen(accountManager.getBalance(account)).thenReturn(balanceAmount3000);\n\t\t\n\t\tprintBalance(balanceAmount3000);\n\t\t\n\t\tp(\"Customer.withdraw(\" + withdrawlAmount2000 + \")\");\n\t\tcustomer.withdraw(withdrawlAmount2000);\n\t\t\n\t\tp(\"Verify order of method calls\");\n\t\tInOrder order = inOrder(accountManager);\n\t\t\n\t\torder.verify(accountManager).findAccount(customer);\n\t\tp(\"Verified findAccount(account) is called\");\n\t\t\n\t\torder.verify(accountManager).getBalance(account);\n\t\tp(\"Verified getBalance(account) is called\");\n\t\t\n\t\torder.verify(accountManager).withdraw(account, withdrawlAmount2000);\n\t\tp(\"Verified withdraw(account, \" +  withdrawlAmount2000 + \") is called\");\n\t\t\n\t\torder.verify(accountManager).getBalance(account);\n\t\tp(\"Verified getBalance(account) is called one more time after withdrawl\");\n\t\t\n\t\tverifyNoMoreInteractions(accountManager);\n\t\tp(\"verified no more calls are executed on the mock object\");\n\t}\n\t\n\tprivate static void p(String text) {\n\t\tSystem.out.println(text);\n\t}\n\t\n\tprivate void printBalance(long balance) {\n\t\tp(\"Balance is \" + balance + \" and withdrawl amount \" + withdrawlAmount2000);\t\n\t}\n}\n<\/pre>\n<p><span style=\"text-decoration: underline;\"><em>Output:<\/em><\/span><\/p>\n<pre class=\"brush:bash; highlight:[9]\">Train getBalance(account) to return 3000\nBalance is 3000 and withdrawl amount 2000\nCustomer.withdraw(2000)\nVerify order of method calls\nVerified findAccount(account) is called\nVerified getBalance(account) is called\nVerified withdraw(account, 2000) is called\nVerified getBalance(account) is called one more time after withdrawl\nverified no more calls are executed on the mock object\nPASSED: withdrawAndVerifyOrder\n<\/pre>\n<h2>6. Download the Eclipse Project<\/h2>\n<p>This was an example of Mockito Verify.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockitoVerify.zip\"><strong>mockitoVerify.zip<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this article, I am going to show you an example of Mockito Verify. To test the state, we use assert, likewise, to verify the test interactions, we use Mockito.verify. Below are my&nbsp;setup details: I am using&nbsp;Maven&nbsp;\u2013 the&nbsp;build tool Eclipse &nbsp;as the&nbsp;IDE, version Luna 4.4.1. TestNG &nbsp;is my&nbsp;testing framework, in case you are new to &hellip;<\/p>\n","protected":false},"author":38,"featured_media":21338,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[923],"tags":[],"class_list":["post-21697","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-mockito"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mockito Verify Example - Examples Java Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"In this article, I am going to show you an example of Mockito Verify. To test the state, we use assert, likewise, to verify the test...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mockito Verify Example - Examples Java Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"In this article, I am going to show you an example of Mockito Verify. To test the state, we use assert, likewise, to verify the test...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2015-03-26T13:00:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-27T12:20:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ram Mokkapaty\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ram Mokkapaty\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/\"},\"author\":{\"name\":\"Ram Mokkapaty\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7b1823eb5bd673bd375f8bee33b70cd8\"},\"headline\":\"Mockito Verify Example\",\"datePublished\":\"2015-03-26T13:00:52+00:00\",\"dateModified\":\"2022-09-27T12:20:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/\"},\"wordCount\":582,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg\",\"articleSection\":[\"Mockito\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/\",\"name\":\"Mockito Verify Example - Examples Java Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg\",\"datePublished\":\"2015-03-26T13:00:52+00:00\",\"dateModified\":\"2022-09-27T12:20:58+00:00\",\"description\":\"In this article, I am going to show you an example of Mockito Verify. To test the state, we use assert, likewise, to verify the test...\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Mockito\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/mockito\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Mockito Verify Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7b1823eb5bd673bd375f8bee33b70cd8\",\"name\":\"Ram Mokkapaty\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/12\/Ram-Mokkapaty-96x96.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/12\/Ram-Mokkapaty-96x96.jpg\",\"caption\":\"Ram Mokkapaty\"},\"description\":\"Ram holds a master's degree in Machine Design from IT B.H.U. His expertise lies in test driven development and re-factoring. He is passionate about open source technologies and actively blogs on various java and open-source technologies like spring. He works as a principal Engineer in the logistics domain.\",\"sameAs\":[\"http:\/\/www.javacodegeeks.com\/\",\"https:\/\/in.linkedin.com\/pub\/ram-satish-mokkapaty\/18\/123\/52b\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/ram-mokkapaty\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mockito Verify Example - Examples Java Code Geeks - 2026","description":"In this article, I am going to show you an example of Mockito Verify. To test the state, we use assert, likewise, to verify the test...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/","og_locale":"en_US","og_type":"article","og_title":"Mockito Verify Example - Examples Java Code Geeks - 2026","og_description":"In this article, I am going to show you an example of Mockito Verify. To test the state, we use assert, likewise, to verify the test...","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2015-03-26T13:00:52+00:00","article_modified_time":"2022-09-27T12:20:58+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg","type":"image\/jpeg"}],"author":"Ram Mokkapaty","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Ram Mokkapaty","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/"},"author":{"name":"Ram Mokkapaty","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7b1823eb5bd673bd375f8bee33b70cd8"},"headline":"Mockito Verify Example","datePublished":"2015-03-26T13:00:52+00:00","dateModified":"2022-09-27T12:20:58+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/"},"wordCount":582,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg","articleSection":["Mockito"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/","name":"Mockito Verify Example - Examples Java Code Geeks - 2026","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg","datePublished":"2015-03-26T13:00:52+00:00","dateModified":"2022-09-27T12:20:58+00:00","description":"In this article, I am going to show you an example of Mockito Verify. To test the state, we use assert, likewise, to verify the test...","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2015\/03\/mockito-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/mockito\/mockito-verify-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"Mockito","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/mockito\/"},{"@type":"ListItem","position":5,"name":"Mockito Verify Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/7b1823eb5bd673bd375f8bee33b70cd8","name":"Ram Mokkapaty","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/12\/Ram-Mokkapaty-96x96.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2014\/12\/Ram-Mokkapaty-96x96.jpg","caption":"Ram Mokkapaty"},"description":"Ram holds a master's degree in Machine Design from IT B.H.U. His expertise lies in test driven development and re-factoring. He is passionate about open source technologies and actively blogs on various java and open-source technologies like spring. He works as a principal Engineer in the logistics domain.","sameAs":["http:\/\/www.javacodegeeks.com\/","https:\/\/in.linkedin.com\/pub\/ram-satish-mokkapaty\/18\/123\/52b"],"url":"https:\/\/examples.javacodegeeks.com\/author\/ram-mokkapaty\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/21697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=21697"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/21697\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/21338"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=21697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=21697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=21697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}