-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* GORM to JPA importer code * resolved code violations * documentation * exclude the example files from the check
- Loading branch information
Showing
21 changed files
with
1,479 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:root-dir: {asciidoctorconfigdir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
:includedir: {asciidoctorconfigdir} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
examples/micronaut-grails-example/grails-app/domain/micronaut/grails/example/User.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2020 Vladimir Orany. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// tag::body[] | ||
package micronaut.grails.example | ||
|
||
import grails.compiler.GrailsCompileStatic | ||
|
||
@GrailsCompileStatic | ||
class User { | ||
|
||
String userName | ||
String password | ||
String email | ||
|
||
static constraints = { | ||
userName blank: false, unique: true | ||
password size: 5..10, blank: false | ||
email email: true, blank: true | ||
} | ||
|
||
} | ||
// end::body[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...es/micronaut-grails-example/src/test/groovy/micronaut/grails/example/GeneratorSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2020 Vladimir Orany. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package micronaut.grails.example | ||
|
||
// tag::body[] | ||
import com.agorapulse.micronaut.grails.jpa.generator.MicronautJpaGenerator | ||
import com.agorapulse.micronaut.grails.test.MicronautGrailsIntegration | ||
import com.agorapulse.testing.fixt.Fixt | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import spock.lang.Specification | ||
|
||
@MicronautGrailsIntegration | ||
class GeneratorSpec extends Specification { | ||
|
||
Fixt fixt = Fixt.create(GeneratorSpec) | ||
|
||
@Autowired MicronautJpaGenerator generator | ||
|
||
void 'generate domains'() { | ||
given: | ||
File root = initRootDirectory() | ||
when: | ||
int generated = generator.generate(root) | ||
then: | ||
noExceptionThrown() | ||
|
||
generated == 1 | ||
|
||
when: | ||
File entityFile = new File(root, 'micronaut/grails/example/User.groovy') | ||
File repositoryFile = new File(root, 'micronaut/grails/example/UserRepository.groovy') | ||
then: | ||
entityFile.exists() | ||
entityFile.text.trim() == fixt.readText('User.groovy.txt').trim() | ||
|
||
repositoryFile.exists() | ||
repositoryFile.text.trim() == fixt.readText('UserRepository.groovy.txt').trim() | ||
} | ||
|
||
private static File initRootDirectory() { | ||
File root = new File(System.getProperty('java.io.tmpdir'), 'micronaut-data-model') | ||
|
||
if (root.exists()) { | ||
root.deleteDir() | ||
} | ||
|
||
root.mkdirs() | ||
|
||
return root | ||
} | ||
|
||
} | ||
// end::body[] |
39 changes: 39 additions & 0 deletions
39
.../micronaut-grails-example/src/test/groovy/micronaut/grails/example/IntegrationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Copyright 2020 Vladimir Orany. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package micronaut.grails.example | ||
|
||
// tag::body[] | ||
import com.agorapulse.micronaut.grails.jpa.generator.MicronautJpaGenerator | ||
import com.agorapulse.micronaut.grails.test.MicronautGrailsIntegration | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import spock.lang.Specification | ||
|
||
@MicronautGrailsIntegration | ||
class IntegrationSpec extends Specification { | ||
|
||
@Autowired MicronautJpaGenerator generator | ||
|
||
void 'application started'() { | ||
when: | ||
new URL("http:https://localhost:$serverPort").text | ||
then: | ||
noExceptionThrown() | ||
} | ||
|
||
} | ||
// end::body[] |
47 changes: 47 additions & 0 deletions
47
...-grails-example/src/test/resources/micronaut/grails/example/GeneratorSpec/User.groovy.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package micronaut.grails.example | ||
|
||
import groovy.transform.CompileStatic | ||
import javax.persistence.Entity | ||
import javax.persistence.GeneratedValue | ||
import javax.persistence.GenerationType | ||
import javax.persistence.Id | ||
import javax.persistence.Table | ||
import javax.persistence.UniqueConstraint | ||
import javax.persistence.Version | ||
import javax.validation.constraints.Email | ||
import javax.validation.constraints.NotBlank | ||
import javax.validation.constraints.NotNull | ||
import javax.validation.constraints.Size | ||
|
||
@Entity | ||
@CompileStatic | ||
@Table( | ||
uniqueConstraints = [ | ||
@UniqueConstraint(columnNames = ['user_name']) | ||
] | ||
) | ||
class User { | ||
|
||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
Long id | ||
|
||
@Version | ||
Long version | ||
|
||
@NotNull | ||
@Size(max = 255) | ||
String email | ||
|
||
@NotNull | ||
@Size(min = 5, max = 10) | ||
@NotBlank | ||
@Size(min = 5, max = 10) | ||
String password | ||
|
||
@NotNull | ||
@NotBlank | ||
@Size(max = 255) | ||
String userName | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...ample/src/test/resources/micronaut/grails/example/GeneratorSpec/UserRepository.groovy.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package micronaut.grails.example | ||
|
||
import io.micronaut.data.annotation.Repository | ||
import io.micronaut.data.repository.CrudRepository | ||
|
||
@Repository | ||
interface UserRepository extends CrudRepository<User, Long> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.