jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.51k stars 4.02k forks source link

UserRepository cannot be converted to BlogSearchRepository #8602

Closed mraible closed 5 years ago

mraible commented 5 years ago
Overview of the issue

A JDL that works with 5.4.2 no longer works with 5.5.0. Here's the JDL:

application {
  config {
    baseName gateway,
    packageName com.okta.developer.gateway,
    applicationType gateway,
    authenticationType oauth2,
    prodDatabaseType postgresql,
    searchEngine elasticsearch,
    serviceDiscoveryType eureka,
    testFrameworks [protractor]
  }
  entities Blog, Post, Tag, Product
}

application {
  config {
    baseName blog,
    packageName com.okta.developer.blog,
    applicationType microservice,
    authenticationType oauth2,
    prodDatabaseType postgresql,
    searchEngine elasticsearch,
    serverPort 8081,
    serviceDiscoveryType eureka
  }
  entities Blog, Post, Tag
}

application {
  config {
    baseName store,
    packageName com.okta.developer.store,
    applicationType microservice,
    authenticationType oauth2,
    databaseType mongodb,
    devDatabaseType mongodb,
    prodDatabaseType mongodb,
    enableHibernateCache false,
    searchEngine elasticsearch,
    serverPort 8082,
    serviceDiscoveryType eureka
  }
  entities Product
}

entity Blog {
  name String required minlength(3),
  handle String required minlength(2)
}

entity Post {
  title String required,
  content TextBlob required,
  date Instant required
}

entity Tag {
  name String required minlength(2)
}

entity Product {
  title String required,
  price BigDecimal required min(0),
  image ImageBlob
}

relationship ManyToOne {
  Blog{user(login)} to User,
  Post{blog(name)} to Blog
}

relationship ManyToMany {
  Post{tag(name)} to Tag{post}
}

paginate Post, Tag with infinite-scroll
paginate Product with pagination

microservice Product with store
microservice Blog, Post, Tag with blog

With 5.5.0, when I run ./mvnw package -Pprod jib:dockerBuild in the blog app's directory, I get a compile error:

[ERROR] /Users/mraible/.../BlogResourceIntTest.java:[86,76] incompatible types: ...repository.UserRepository cannot be converted to ...repository.search.BlogSearchRepository
Motivation for or Use Case

Demo fear.

Reproduce the error

Use the JDL above with jhipster import-jdl apps.jdl with 5.5.0. It will fail when you try to build Docker containers. It works when you use 5.4.2.

JHipster Version(s)
gateway@0.0.0 /Users/mraible/connect-tech/gateway
└── generator-jhipster@5.5.0
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "clientPackageManager": "npm",
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "enableHibernateCache": true,
    "enableSwaggerCodegen": false,
    "enableTranslation": true,
    "jhiPrefix": "jhi",
    "languages": [
      "en",
      "fr"
    ],
    "messageBroker": false,
    "nativeLanguage": "en",
    "packageName": "com.okta.developer.gateway",
    "packageFolder": "com/okta/developer/gateway",
    "prodDatabaseType": "postgresql",
    "searchEngine": "elasticsearch",
    "serviceDiscoveryType": "eureka",
    "skipClient": false,
    "skipServer": false,
    "testFrameworks": [
      "protractor"
    ],
    "websocket": false,
    "baseName": "gateway",
    "applicationType": "gateway",
    "authenticationType": "oauth2",
    "jhipsterVersion": "5.5.0",
    "buildTool": "maven",
    "skipUserManagement": true,
    "cacheProvider": "hazelcast",
    "serverPort": "8080",
    "clientFramework": "angularX",
    "useSass": true
  },
  "entities": [
    "Blog",
    "Post",
    "Tag",
    "Product"
  ]
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Blog {
  name String required minlength(3),
  handle String required minlength(2)
}
entity Post {
  title String required,
  content TextBlob required,
  date Instant required
}
entity Tag {
  name String required minlength(2)
}
entity Product {
  title String required,
  price BigDecimal required min(0),
  image ImageBlob
}
relationship ManyToOne {
  Blog{user(login)} to User,
  Post{blog(name)} to Blog
}
relationship ManyToMany {
  Post{tag(name)} to Tag{post}
}

microservice Blog, Post, Tag with blog
paginate Post, Tag with infinite-scroll
paginate Product with pagination
microservice Product with store

Environment and Tools

openjdk version "1.8.0_181" OpenJDK Runtime Environment (Zulu 8.31.0.1-macosx) (build 1.8.0_181-b02) OpenJDK 64-Bit Server VM (Zulu 8.31.0.1-macosx) (build 25.181-b02, mixed mode)

git version 2.17.1 (Apple Git-112)

node: v8.11.3

npm: 6.4.1

yeoman: 2.0.5

yarn: 1.10.1

Docker version 18.06.1-ce, build e68fc7a

docker-compose version 1.22.0, build f46880f

mraible commented 5 years ago

Here's the generated constructor for BlogResource:

public BlogResource(BlogRepository blogRepository, BlogSearchRepository blogSearchRepository, UserRepository userRepository) {
    this.blogRepository = blogRepository;
    this.blogSearchRepository = blogSearchRepository;
    this.userRepository = userRepository;
}

While the generated BlogResourceIntTest has the search repository as the 2nd argument:

final BlogResource blogResource = new BlogResource(blogRepository, userRepository, mockBlogSearchRepository);
deepu105 commented 5 years ago

Seems like a missing condition somewhere. I think we need to test things better before merging PRs and also may be cover more cases in CI

Thanks & Regards, Deepu

On Thu, Oct 18, 2018 at 5:18 PM Matt Raible notifications@github.com wrote:

Here's the generated constructor for BlogResource:

public BlogResource(BlogRepository blogRepository, BlogSearchRepository blogSearchRepository, UserRepository userRepository) { this.blogRepository = blogRepository; this.blogSearchRepository = blogSearchRepository; this.userRepository = userRepository; }

While the generated BlogResourceIntTest has the search repository as the 2nd argument:

final BlogResource blogResource = new BlogResource(blogRepository, userRepository, mockBlogSearchRepository);

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/8602#issuecomment-431049846, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDlFxIkYfhhecCovOJdcSld63xKtxDKks5umJurgaJpZM4Xsok9 .

Falydoor commented 5 years ago

My bad guys, I knew that my refactor will cause some issues and I did not test correctly.