Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@PropertyName is ignored in Shadows creation #574

Closed
bartoszwalacik opened this issue Jul 31, 2017 · 4 comments
Closed

@PropertyName is ignored in Shadows creation #574

bartoszwalacik opened this issue Jul 31, 2017 · 4 comments

Comments

@bartoszwalacik
Copy link
Member

it causes unexpected nulls in Shadows, reproduction scenario:

class CaseShadowWithPropertyName extends Specification {

    class Entity {
        @Id int id
        @PropertyName("otherField") String someField
    }

    def "should use @PropertyName when creating Shadows"(){
      given:
      def javers = JaversBuilder.javers().build()
      def e = new Entity(id:1, someField: "s")
      javers.commit("author", e)

      when:
      def shadow = javers.findShadows(QueryBuilder.byInstance(e).build()).get(0).get()

      then:
      shadow instanceof Entity
      shadow.id == 1
      shadow.someField == "s"
    }
}
@pszymczyk
Copy link
Contributor

pszymczyk commented Sep 22, 2017

Is last line in then section correct? Did you mean shadow.someField == "s" or shadow. otherField == "s" ?

@bartoszwalacik
Copy link
Member Author

yes, it's correct.
shadow.someField isn't populated

@pszymczyk
Copy link
Contributor

The simplest workaround is to annotate field with Gson annotation @SerializedName("otherField") but it's not final solution for sure.

@bartoszwalacik
Copy link
Member Author

fix released in 3.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants