Giter VIP home page Giter VIP logo

fixy's People

Contributors

andrey-fomin avatar collisonchris avatar eskatos avatar jnehlmeier avatar mmounirou avatar sberan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fixy's Issues

How to load a java.util.Set with fixy

When I try to load a sequence into an object of type java.io.Set I got following exception :

org.yaml.snakeyaml.error.YAMLException: org.yaml.snakeyaml.error.YAMLException: Cannot set property='children' with value='[Person [firstName=Bill, secondName=Lumbergh], Person [firstName=Jane, secondName=Lumbergh]]' (class java.util.ArrayList) in Person [firstName=Paul, secondName=Lumbergh]
    at org.yaml.snakeyaml.extensions.compactnotation.CompactConstructor$ConstructCompactObject.construct(CompactConstructor.java:163)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:183)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructSequenceStep2(BaseConstructor.java:277)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructSequence(BaseConstructor.java:248)
    at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlSeq.construct(SafeConstructor.java:440)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:183)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:142)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:128)
    at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:480)
    at org.yaml.snakeyaml.Yaml.load(Yaml.java:411)
    at com.pearson.fixy.Fixy.loadEntities(Fixy.java:105)
    at com.pearson.fixy.Fixy.load(Fixy.java:126)
    at com.dvidea.TestFixy.test(TestFixy.java:24)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    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.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    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.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.yaml.snakeyaml.error.YAMLException: Cannot set property='children' with value='[Person [firstName=Bill, secondName=Lumbergh], Person [firstName=Jane, secondName=Lumbergh]]' (class java.util.ArrayList) in Person [firstName=Paul, secondName=Lumbergh]
    at org.yaml.snakeyaml.extensions.compactnotation.CompactConstructor.setProperties(CompactConstructor.java:89)
    at org.yaml.snakeyaml.extensions.compactnotation.CompactConstructor$ConstructCompactObject.construct(CompactConstructor.java:161)
    ... 34 more

Do you know any tips to load a set instead of a list ?

Publish Fixy 2.1

Fixy 2.0 is the last published version and is now 2 years old.

The master branch has many interesting changes such as field access support.

It would be great to get Fixy 2.1 published.

Import loop causes Fixy to use wrong packageName value in CoreFixy.getClassForName()

Assume the following classes:

a.A, b.B, c.C and d.D

Each class has its own yaml file and !import is used based on the class dependencies:

a.A -> b.B -> c.C -> d.D -> b.B

What now happens is that CoreFixy.loadEntities() is called in the above order but is not called for the last b.B import since that import has already been seen earlier, see CoreFixy.ConstructImport.construct().

So while processing the d.yaml file, SnakeYaml wants to create an instance of b.B because D references a B. But since no b.B instances have been created yet the entityCache of CoreFixy does not have any cached instance and calls super.createInstance() which in turn calls CoreFixy.getClassforName() at some point. However the package name is set to d (because we process the d.yaml file) so getClassForName() now tries to load the class d.B which fails with a ClassNotFoundException.

Allow Pluggable Persistence Backends

Currently, Fixy only works with JPA. It would be nice if it worked for multiple ORMs such as Hibernate, EBean, Morphia, etcetera.

What we probably need is a Persister class which knows how to take an entity and persist it. The default persister should be the JPA persister.

Provide a way to configure Yaml.setBeanAccess()

Currently entities with immutable fields can not be created by Fixy because SnakeYaml, by default, follows the Java Bean spec to fill properties (public fields or getter/setter). But for immutable fields you only have a getter and private fields (e.g. the ID of an entity). SnakeYaml supports this by using BeanAccess.FIELD.

I created a fork of Fixy and I can see two ways to fix this issue:

  1. Immutable version that adds a constructor parameter to CoreFixy and provides additional factory methods in JPAFixy (that would nearly double the factory method count).
  2. Mutable version that defines setFieldAccess(boolean) on the Fixy interface.

In both cases I would store the information in a field and use it in loadEntities(String...) to configure the internal yaml instance.

Which way would you prefer?

Error reporting: unknown instance

When an object is referred to via a label, Fixy should report an error if there is no object with that label. For instance:

- Employee(bob):
  name: Bob

- Employee(bill):
  - name: Bill
  - manager: Employee(blob)

The last line should throw an error: no employee found:blob

The line number should be reported as well.

This will probably require a deep dive into snakeYaml. Consider examining the output of the yaml parser after it is created rather than trying to find occurrences while parsing the yaml.

Merge detached entities

Hello. We are using Fixy to insert data in our PostgreSQL database and it is working well so far. However, I now need to insert some entities with a static id and would like to insert them with their foreign keys set. I have checked out the source code for Fixy and notices that you call persist only in the EntityManager.

Do you have any recommendation for being able to declare and persist detached entities in Fixy (and thus be able to set the primary key in my fixtures)?

fix example on main page

Hi. Really nice API there which has made my unit-testing life (outside of using Play framework) quite a bit easier. Also thanks for making it available through Maven.

I have one suggestion that slowed me down for about half an hour and made me unnecessarily curse you - you may want to actually mention in your example code on the front page that you need to manually start a transaction before loading the fixtures. Otherwise you get no error but no data in the database either, of course I was naturally assuming that I somehow screwed up my exploratory yaml file :)

Its just fine that you have unit tests in the source code that act as the 'full' documentation of the library, but you might want to mention that directly in the example on the main page as one of the first things you read in stead of at the very end of the page. For too long I was left thinking that the little bit of text was the only documentation I was going to get and I was already quite ready to just give up on using Fixy because of that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.