java.lang.AssertionError: Model attribute 'restaurants' Expected: a collection with size <2> but: collection size was <0>

Stack Overflow | Alexander Not | 6 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Testing model attribute in Spring Boot Controllers

    Stack Overflow | 6 months ago | Alexander Not
    java.lang.AssertionError: Model attribute 'restaurants' Expected: a collection with size <2> but: collection size was <0>
  2. 0

    Spring Security Authentication Test user property null

    Coderanch | 9 months ago | Stefano Carniel
    java.lang.AssertionError: Model attribute 'reader' Expected: same property values as Reader [accountNonExpired: <true>, accountNonLocked: <true>, authorities: <[ROLE_READER]>, credentialsNonExpired: <true>, enabled: <true>, fullname: "Stefano Carniel", password: "password", username: "stefano"] but: fullname was null
  3. 0

    Getting null for form parameter in Spring Test Framework Controller test

    Stack Overflow | 1 year ago | Meena Chaudhary
    java.lang.AssertionError: Model attribute 'username' Expected: is "somebody@gmail.com" got: null
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    GitHub comment 527#213480179

    GitHub | 10 months ago | markpollack
    java.lang.AssertionError: JSON path "$.page.totalElements" Expected: is <2> but: was <3>
  6. 0

    GitHub comment 75#240384625

    GitHub | 6 months ago | fraenkel
    java.lang.AssertionError: JSON path "$" Expected: iterable over ["Recurring Schedule 0 end_time and Recurring Schedule 1 start_time are overlapping."] in any order but: Not matched: "Recurring Schedule 0 end_time 05:00 should be after start_time 19:00."
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.AssertionError

    Model attribute 'restaurants' Expected: a collection with size <2> but: collection size was <0>

    at org.hamcrest.MatcherAssert.assertThat()
  2. Hamcrest
    MatcherAssert.assertThat
    1. org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
    1 frame
  3. Spring TestContext
    MockMvc$1.andExpect
    1. org.springframework.test.web.servlet.result.ModelResultMatchers$1.match(ModelResultMatchers.java:58)
    2. org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:171)
    2 frames
  4. com.matmr.restaurantpoll
    RestaurantControllerTest.should_search
    1. com.matmr.restaurantpoll.controller.RestaurantControllerTest.should_search(RestaurantControllerTest.java:79)
    1 frame
  5. Java RT
    Method.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    4. java.lang.reflect.Method.invoke(Method.java:497)
    4 frames
  6. JUnit
    RunBefores.evaluate
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    4. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    5. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    5 frames
  7. Spring TestContext
    SpringRepeat.evaluate
    1. org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
    2. org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
    3. org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
    3 frames
  8. JUnit
    ParentRunner.runLeaf
    1. org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    1 frame
  9. Spring TestContext
    SpringJUnit4ClassRunner.runChild
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252)
    2. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94)
    2 frames
  10. JUnit
    ParentRunner$2.evaluate
    1. org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    2. org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    3. org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    4. org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    5. org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    5 frames
  11. Spring TestContext
    RunAfterTestClassCallbacks.evaluate
    1. org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
    2. org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
    2 frames
  12. JUnit
    ParentRunner.run
    1. org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    1 frame
  13. Spring TestContext
    SpringJUnit4ClassRunner.run
    1. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191)
    1 frame
  14. JUnit4 Runner
    JUnit4TestReference.run
    1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    1 frame
  15. JUnit3 Runner
    RemoteTestRunner.main
    1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
    5 frames