Skip to content

Commit 3566782

Browse files
authored
Test cases for broken mapped entities (#2936)
1 parent 25a7a06 commit 3566782

15 files changed

+293
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.micronaut.data.jdbc.h2
17+
18+
19+
import io.micronaut.test.extensions.spock.annotation.MicronautTest
20+
import jakarta.inject.Inject
21+
import spock.lang.Specification
22+
23+
@MicronautTest
24+
@H2DBProperties
25+
class H2MappedEntitySpec extends Specification {
26+
@Inject
27+
H2DoubleImplement1Repository di1
28+
@Inject
29+
H2DoubleImplement2Repository di2
30+
@Inject
31+
H2DoubleImplement3Repository di3
32+
33+
void "test mapped entities with multiple interfaces"() {
34+
when: "First implementation"
35+
def results1 = di1.get()
36+
37+
then: "The result is correct"
38+
results1 != null
39+
40+
when: "Second implementation"
41+
def results2 = di2.get()
42+
43+
then: "The result is correct"
44+
results2 != null
45+
46+
when: "Second implementation"
47+
def results3 = di3.get()
48+
49+
then: "The result is correct"
50+
results3 != null
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.micronaut.data.jdbc.h2;
17+
18+
import io.micronaut.data.jdbc.annotation.JdbcRepository;
19+
import io.micronaut.data.model.query.builder.sql.Dialect;
20+
import io.micronaut.data.tck.repositories.CarRepository;
21+
import io.micronaut.data.tck.repositories.DoubleImplement1Repository;
22+
23+
@JdbcRepository(dialect = Dialect.H2)
24+
public interface H2DoubleImplement1Repository extends DoubleImplement1Repository {
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.micronaut.data.jdbc.h2;
17+
18+
import io.micronaut.data.jdbc.annotation.JdbcRepository;
19+
import io.micronaut.data.model.query.builder.sql.Dialect;
20+
import io.micronaut.data.tck.repositories.DoubleImplement2Repository;
21+
22+
@JdbcRepository(dialect = Dialect.H2)
23+
public interface H2DoubleImplement2Repository extends DoubleImplement2Repository {
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.micronaut.data.jdbc.h2;
17+
18+
import io.micronaut.data.jdbc.annotation.JdbcRepository;
19+
import io.micronaut.data.model.query.builder.sql.Dialect;
20+
import io.micronaut.data.tck.repositories.DoubleImplement3Repository;
21+
22+
@JdbcRepository(dialect = Dialect.H2)
23+
public interface H2DoubleImplement3Repository extends DoubleImplement3Repository {
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.micronaut.data.tck.entities;
2+
3+
import io.micronaut.data.annotation.MappedEntity;
4+
5+
@MappedEntity
6+
public class DoubleImplement1 implements DoubleImplementB1 {
7+
int a;
8+
int b;
9+
10+
public DoubleImplement1(int a, int b) {
11+
this.a = a;
12+
this.b = b;
13+
}
14+
15+
@Override
16+
public int getA() {
17+
return this.a;
18+
}
19+
20+
@Override
21+
public int getB() {
22+
return this.b;
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.micronaut.data.tck.entities;
2+
3+
import io.micronaut.data.annotation.MappedEntity;
4+
5+
@MappedEntity
6+
public class DoubleImplement2 implements DoubleImplementB2 {
7+
int a;
8+
int b;
9+
10+
public DoubleImplement2(int a, int b) {
11+
this.a = a;
12+
this.b = b;
13+
}
14+
15+
@Override
16+
public int getA() {
17+
return this.a;
18+
}
19+
20+
@Override
21+
public int getB() {
22+
return this.b;
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.micronaut.data.tck.entities;
2+
3+
import io.micronaut.data.annotation.MappedEntity;
4+
5+
@MappedEntity
6+
public class DoubleImplement3 implements DoubleImplementA, DoubleImplementB3 {
7+
int a;
8+
int b;
9+
10+
public DoubleImplement3(int a, int b) {
11+
this.a = a;
12+
this.b = b;
13+
}
14+
15+
@Override
16+
public int getA() {
17+
return this.a;
18+
}
19+
20+
@Override
21+
public int getB() {
22+
return this.b;
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package io.micronaut.data.tck.entities;
2+
3+
interface DoubleImplementA {
4+
int getA();
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package io.micronaut.data.tck.entities;
2+
3+
interface DoubleImplementB1 extends DoubleImplementA {
4+
int getB();
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.micronaut.data.tck.entities;
2+
3+
interface DoubleImplementB2 extends DoubleImplementA {
4+
int getA();
5+
int getB();
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.micronaut.data.tck.entities;
2+
3+
interface DoubleImplementB3 {
4+
int getA();
5+
int getB();
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.micronaut.data.tck.repositories;
17+
18+
import io.micronaut.data.annotation.Query;
19+
import io.micronaut.data.tck.entities.DoubleImplement1;
20+
21+
public interface DoubleImplement1Repository {
22+
@Query("select 2 as a, 3 as b")
23+
DoubleImplement1 get();
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.micronaut.data.tck.repositories;
17+
18+
import io.micronaut.data.annotation.Query;
19+
import io.micronaut.data.tck.entities.DoubleImplement2;
20+
21+
public interface DoubleImplement2Repository {
22+
@Query("select 2 as a, 3 as b")
23+
DoubleImplement2 get();
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.micronaut.data.tck.repositories;
17+
18+
import io.micronaut.data.annotation.Query;
19+
import io.micronaut.data.tck.entities.DoubleImplement3;
20+
21+
public interface DoubleImplement3Repository {
22+
@Query("select 2 as a, 3 as b")
23+
DoubleImplement3 get();
24+
}

gradle/libs.versions.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
2-
micronaut = "4.4.7"
3-
micronaut-platform = "4.3.7"
2+
micronaut = "4.4.9"
3+
micronaut-platform = "4.4.2"
44
micronaut-docs = "2.0.0"
55
micronaut-gradle-plugin = "4.4.0"
66
micronaut-testresources = "2.5.2"

0 commit comments

Comments
 (0)