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 8884559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:05:22+00:00 2026-06-14T21:05:22+00:00

I use festAssertions in my tests and I noticed that using assertThat(object).isEqualTo(otherObject) yields different

  • 0

I use festAssertions in my tests and I noticed that using assertThat(object).isEqualTo(otherObject) yields different results than assertThat(object.equals(otherObject)).isTrue(); in tests where hibernate objects are tested.

I had to do workaround and now test looks really ugly but I cannot use
assertThat(collection).contains(object1, object2) because that just does not work!

Here is partial code(look at last line):
seasonRate, seasonRate1 are created and persisted. Then retrieved from db and checked against originals. Nothing fancy, but does not work with festAssertions.

Do you have any idea how to fix that and if it is some error on my side or not?

    (...)
    session.save(seasonRate);
    session.save(seasonRate2);

    session.getTransaction().commit();
    session.close();


    session = sessionFactory.getCurrentSession();
    session.beginTransaction();
    RateRepositoryHibernate rateRepositoryHibernate= new RateRepositoryHibernate(new StubHibernateSessionFactory(sessionFactory));
    // when
    final Collection<Rate> allRatesForRoom = rateRepositoryHibernate.getAllRatesForRoom(room);

    // then
    assertThat(allRatesForRoom.size()).isEqualTo(EXPECTED_RATES);
    for(Rate rate : allRatesForRoom)
    {
        if(rate.getRateName().equals("season name 2"))
        {
            assertThat(rate.equals(seasonRate2)).isTrue();
        }
        if(rate.getRateName().equals("season name"))
        {
            assertThat(rate.equals(seasonRate)).isTrue();
        }
    }
    //assertThat(allRatesForRoom).contains(seasonRate, seasonRate2); // this does not work somehow
  • 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-06-14T21:05:23+00:00Added an answer on June 14, 2026 at 9:05 pm

    It turns out that this is not festAssertions issue because after changes to code I cannot reproduce that bug and .contains method works nicely.

    My changes were related to current session concept and I probably had some bad code.

    If you happen to face similar issue then you should look for problems in your hibernate related code and configuration but not inside festAssertions.

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

Sidebar

Related Questions

Use scenario is pretty simple: I have a desktop only application that could be
Use case: I find a piece of code that I do not understand at
use case example I have a servlet that is receiving login requests. If a
Use AES/Rijndael or any symmetric encryption. Encrypt the hidden value using itself as the
Use http://jobs.sitesixteen.com/ for reference. I'm using YQL for the city, state auto-complete. IF you
use ThreadPool.QueueUserWorkItem (WaitCallback, Object) to start a thread with my target method and data.
Use acts-as-taggable-on for tagging. Based previous questions in SO i read that i must
USE [Fk_Test2] GO /****** Object: Table [dbo].[Owners] Script Date: 08/20/2010 16:52:44 ******/ SET ANSI_NULLS
Use case: I'm using data templates to match a View to a ViewModel. Data
Use Case Show a photo uploaded by the user in a square box with

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.