Home > Mobile >  Is ArgumentCaptor changing the value of a generated field?
Is ArgumentCaptor changing the value of a generated field?

Time:10-11

I have an object with a field id, that is a generated UUID:

id = UUID.randomUUID().toString()

I use this in a method where I save the object:

saveObject(SomeObject someObject) {
    someRepository.saveObject(someTestObject.id, //other fields)
}

But when I use ArgumentCaptor in my test:

verify(someRepository, times(1)).save(ntCaptor.capture());
aasertThat(ntCaptor.getValue(),
    allOf(
        hasProperty("id", is(someObject.getId),
        // other fields
    )

I get a different id that I save. Is this a bug or is there a different approach to capture generated values?

CodePudding user response:

In this:

saveObject(SomeObject someObject) {
    someRepository.saveObject(someTestObject.id, //other fields)
}

maybe because you are not using the someObject, you are using someTestObject.

  • Related