Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7402059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:38:42+00:00 2026-05-29T04:38:42+00:00

I am getting the following error when testing my DAO using Assert.AssertEquals() method: java.lang.AssertionError:

  • 0

I am getting the following error when testing my DAO using Assert.AssertEquals() method:

java.lang.AssertionError: expected: com.develop.test.data.entity.Rpoint<com.develop.test.data.entity.Rpoint@7668e5b5> but was: com.develop.test.data.entity.Rpoint<com.develop.test.data.entity.Rpoint@7668e5b5>
at org.junit.Assert.fail(Assert.java:91)
at org.junit.Assert.failNotEquals(Assert.java:645)
at org.junit.Assert.assertEquals(Assert.java:126)
at org.junit.Assert.assertEquals(Assert.java:145)
at com.develop.test.data.dao.RpointDAOTest.testFindById(RpointDAOTest.java:80)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Here’s the snippet:

@Test
@Transactional(isolation = Isolation.SERIALIZABLE)
public void testFindById(){
    Category newCategory = new Category("C", "Recognize a Co-Worker", true);

    Rpoint newRPoint = new Rpoint.Builder()
                .id(3)
                .category(newCategory)                    
                .description("Maximize Resources")
                .points(50)
                .active(true)
                .build();

    Assert.assertEquals(newRPoint, this.RpointDao.findById(3));
}

I’ve been using debug, and both entities have the same data. Could this be caused by the equals/HashCode implementation in the entity?

Edit: added equals and hashcode:

@Override
public boolean equals(Object instance) {
    if (instance == null)
        return false;

    if (!(instance instanceof Rpoint))
        return false;

    Rpoint o = (Rpoint) instance;
    return new EqualsBuilder().append(this.getId(), o.getId()).
            append(this.getCategory(), o.getCategory()).
            append(this.getDescription(), o.getDescription()).
            append(this.getPoints(), o.getPoints()).
            append(this.getActive(), o.getActive()).
            isEquals();
}

@Override
public int hashCode() {
    return new HashCodeBuilder(23, 25).append(this.getId()).
            append(this.getCategory()).
            append(this.getDescription()).
            append(this.getPoints()).
            append(this.getActive()).
            toHashCode();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:38:43+00:00Added an answer on May 29, 2026 at 4:38 am

    Yes, if equals is implemented badly so that it returns false even if you use the same reference, this would definitely cause the failure. Note that it’s not just a case of the data within the object being the same, but the diagnostics suggest it’s the same object on both sides:

    expected [...].Rpoint<com.develop.test.data.entity.Rpoint@7668e5b5>
    but was: [...].Rpoint<com.develop.test.data.entity.Rpoint@7668e5b5>
    

    The 7668e5b5 shouldn’t really be treated as object identity, but it’s extremely suggestive here…

    Please show the equals method you’re using.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting following error when I am trying to get WebResponse using WebResponse
I am getting following error message when using Doctrine ORM in Codeigniter. ( !
I have done simple java app for blackberry, while building am getting following error.
I am getting the following error: Access denied for user 'apache'@'localhost' (using password: NO)
I'm getting the following error while testing my EHAB implementation: ArgumentException - Event log
Why i am getting following error while testing the application? App1 does not specify
I am getting the following error using Crystal Reports 10.5 on my development machine.
I am continually getting the following error during testing: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to
I am trying to send email through gmail using PHPMailer_V5.1. Getting the following error,
I'm getting the following error after testing my Flash game's code: ArgumentError: Error #1063:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.