Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 15 21:43

    xvik on gh-pages

    Publish 5.4.1 documentation (compare)

  • Jan 15 21:41

    xvik on gh-pages

    Publish 5.4.1 documentation (compare)

  • Jan 15 21:22

    xvik on master

    update docs for updated extensi… (compare)

  • Jan 13 11:10

    dependabot[bot] on gradle

    (compare)

  • Jan 13 11:10

    xvik on master

    Bump com.gradle.enterprise from… Merge pull request #211 from xv… (compare)

  • Jan 13 11:10
    xvik closed #211
  • Jan 13 05:36
    Kalyan-M closed #208
  • Jan 13 05:36
    Kalyan-M commented #208
  • Jan 12 23:42
    codecov-commenter commented #211
  • Jan 12 23:38
    codecov-commenter commented #211
  • Jan 12 23:38
    codecov-commenter commented #211
  • Jan 12 23:38
    codecov-commenter commented #211
  • Jan 12 23:38
    codecov-commenter commented #211
  • Jan 12 23:37
    codecov-commenter commented #211
  • Jan 12 23:33
    codecov-commenter commented #211
  • Jan 12 23:13
    dependabot[bot] labeled #211
  • Jan 12 23:13
    dependabot[bot] opened #211
  • Jan 12 23:13

    dependabot[bot] on gradle

    Bump com.gradle.enterprise from… (compare)

  • Jan 12 13:15

    xvik on master

    fix bom module link (compare)

  • Jan 06 19:21
    xvik commented #208
Vyacheslav Rusakov
@xvik
You will need to use guicey @InTransaction annotation instead of it (to declare unit of work scope).
Shachar Levy
@levyshachar2
It seems I still get the error even when I don't call the transaction
Simple get DAO call

fun getFooById(fooId: String): FooDto { val foo = fooDao.getFooByFooId(fooId) return foo.toDto() }

this is my function , where fooDAO is getting injected in the constructor
I'm still getting the error Unit of work not started yet

my fooDao is defined as

@JdbiRepository interface fooDAO { }

Vyacheslav Rusakov
@xvik
@levyshachar2 problem may be caused by kotlin: by default it makes all methods final and so guice could not apply AOP on them (transaction support is AOP based). It's easy to check: use aop diagnostic report to see if your method (or dao calling method, depends on where you put InTransaction annotation) is handled with aop
Shachar Levy
@levyshachar2
But i'm not using the InTransaction annotation in this function at all , do I need to add the open key anyway for that function?
Vyacheslav Rusakov
@xvik
The error telling that you're calling your dao method not withing unit of work
Shachar Levy
@levyshachar2
I don't need transaction in that function , as it just a simple get
Vyacheslav Rusakov
@xvik
Unit of work may be automatic with InTransaction annotation: in this case you need to annotate called dao method or any method calling this method
or you can declare unit of work manually
in any case your dao methods must be called within unit of work
Usually I put InTransaction directly on dao interfaces declaring the smallest unit of work (dao method call will not fail in any case)
Shachar Levy
@levyshachar2
so basically every function in my DAO should be in some transaction , either with the InTransaction annotation or manually?
Vyacheslav Rusakov
@xvik
Yes, unit of work == transaction (just dropwizard use this term for hibernate so I used it too in this module to unify meaning)
Shachar Levy
@levyshachar2

ok , so if I want to do a transaction of two DAO function calls , I will have another @InTransaction annotation for the function

@InTransaction
fun fooAndGoo() { fooDao.DoSomething() gooDao.doSomething() }

?

Vyacheslav Rusakov
@xvik
Annotation declares scope: annoting method means transaction scope will equal to this method. You can call any (number) of dao methods within this method and they would be called at the same transaction
if you put InTransaction at the class level it would affect all methods. So when I annotate DAO interface I declare minimal transaction scope (any called method would create its own transaction)
Shachar Levy
@levyshachar2
Got it , thank you!
Vyacheslav Rusakov
@xvik
If you have some annotated service method which calls muliple dao methods then you enlarge transaction scope (annotation on dao interface ignored in this case and all methods will be called at the same transaction)
Shachar Levy
@levyshachar2
so basically the top layer annotation defined the daos for all the transaction
Vyacheslav Rusakov
@xvik
top layer annotation defines actual transaction scope other scope declarations inside it are ignored (as scope already opened)
usually transaction scope is declared on service layer (rest is too early to avoid transport errors and dao is too low).. but not a rule ofc (dropwizard-hibernate prefer rest method scoped transactions).
Shachar Levy
@levyshachar2

@xvik Hi , I have a small question.
In our testing we are using GuiceyAppRule to start our service from within the tests.
To define the GuiceyAppRule we need to provide the path to the config.yaml file, however our config files are residing in the Src folder and not in the test folder, which makes it fails to find the configuration files.
As a temp workaround , we copied the files from the Src also to the test folder.
We were wandering if there is a better alternative for that , didn't find something in the documentation.

thank you

Vyacheslav Rusakov
@xvik
@levyshachar2 Hi! That's strange because I always specify config paths from project root, for example https://github.com/xvik/dropwizard-guicey-examples/blob/master/ext-jdbi3/src/test/groovy/ru/vyarus/dropwizard/guice/examples/UserRepositoryTest.groovy#L13. But it's in gralde. I don't remember what is the default in maven.
There is no magic applied to config paths, it's just passed to dropwizard as is (only working dir is important). But still, even if your work dir is lower then project root you can try to use backwards navigation like "../../main/resources/.."
Vyacheslav Rusakov
@xvik
You also can (not a very good idea, but still) specify custom ConfigurationSourceProviderin bootstrap object (using guicey hook) and find correct file there.
Shachar Levy
@levyshachar2
Thank you for your help , ill try it
John LaBarge
@johnlabarge
Hi I'm new to dropwizard-guicey and trying to figure out how to test a rest resource is t here an example somewhere?
Vyacheslav Rusakov
@xvik
@johnlabarge hi! You have 2 ways:
  1. Use dropwizard testing approach which is basically unit tests with dependencies mocking
  2. Use integration tests (and I prefer this one): when test starts complete web application and you call rest services with a client
For the later, guicey provides testing extension and pre-configured client
There are also juni4 and spock extensions, but junit 4 version lacks client support (you will have to instantiate client manually). And, if possible, prefer junit 5
John LaBarge
@johnlabarge
trying to figure out where the. "Specification" class comes from.
Vyacheslav Rusakov
@xvik
oh! its a mistake, sorry .. junit example was based on spock example
no need to extend anything for junit
John LaBarge
@johnlabarge
so how does the ClientSupport object injection work?
when I try to run it I get an error : should have no parameters
example test, ignore @Nested - its not important.. just was used for this exact test
ClientSupport is injected as test method parameter (could be also used as Before/after method parameter)
John LaBarge
@johnlabarge
yeah when I try to do that I'm getting "should 0have no parameters" exception
Trying to figure out what I'm missing
Vyacheslav Rusakov
@xvik
are you using junit 5?
John LaBarge
@johnlabarge
I think so
oop
*oops had a stray 4 dependency in my gradle file
still same issue :(
may need a clean
Vyacheslav Rusakov
@xvik
junit4 dependency itself is not a problem as junit5 use completely different package (and so even different Test annotation class)
John LaBarge
@johnlabarge
the exception is coming from here though: at org.junit.internal.builders.JUnit4Builder.runnerForClass(JUnit4Builder.java:10)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
Vyacheslav Rusakov
@xvik
seems junit 4 tries to run it
are you using gradle to run tests?