Skip to content

Commit 650a213

Browse files
committed
test: enhance program and comoputer using the factory method
Signed-off-by: Otavio Santana <[email protected]>
1 parent 2485f27 commit 650a213

File tree

3 files changed

+144
-2
lines changed

3 files changed

+144
-2
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,73 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
115
package org.eclipse.jnosql.databases.mongodb.integration;
216

17+
import jakarta.nosql.Column;
18+
import jakarta.nosql.Entity;
19+
import jakarta.nosql.Id;
20+
21+
import java.util.Map;
22+
import java.util.Objects;
23+
24+
@Entity
325
public class Computer {
26+
@Id
27+
private String name;
28+
29+
@Column
30+
private Map<String, Program> programs;
31+
32+
private Computer(String name, Map<String, Program> programs) {
33+
this.name = name;
34+
this.programs = programs;
35+
}
36+
37+
@Deprecated
38+
Computer() {
39+
}
40+
41+
public String getName() {
42+
return name;
43+
}
44+
45+
public Map<String, Program> getPrograms() {
46+
return programs;
47+
}
48+
49+
@Override
50+
public boolean equals(Object o) {
51+
if (o == null || getClass() != o.getClass()) return false;
52+
Computer computer = (Computer) o;
53+
return Objects.equals(name, computer.name);
54+
}
55+
56+
@Override
57+
public int hashCode() {
58+
return Objects.hashCode(name);
59+
}
60+
61+
@Override
62+
public String toString() {
63+
return "Computer{" +
64+
"name='" + name + '\'' +
65+
", programs=" + programs +
66+
'}';
67+
}
68+
69+
70+
public static Computer of(String name, Map<String, Program> programs) {
71+
return new Computer(name, programs);
72+
}
473
}
Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,72 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
* All rights reserved. This program and the accompanying materials
4+
* are made available under the terms of the Eclipse Public License v1.0
5+
* and Apache License v2.0 which accompanies this distribution.
6+
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7+
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
8+
*
9+
* You may elect to redistribute this code under either of these licenses.
10+
*
11+
* Contributors:
12+
*
13+
* Otavio Santana
14+
*/
115
package org.eclipse.jnosql.databases.mongodb.integration;
216

3-
public record Program() {
4-
}
17+
import jakarta.nosql.Column;
18+
import jakarta.nosql.Embeddable;
19+
import jakarta.nosql.Id;
20+
21+
import java.util.Map;
22+
import java.util.Objects;
23+
24+
@Embeddable
25+
public class Program {
26+
@Id
27+
private String name;
28+
29+
@Column
30+
private Map<String, String> socialMedia;
31+
32+
public String getName() {
33+
return name;
34+
}
35+
36+
public Map<String, String> getSocialMedia() {
37+
return socialMedia;
38+
}
39+
40+
private Program(String name, Map<String, String> socialMedia) {
41+
this.name = name;
42+
this.socialMedia = socialMedia;
43+
}
44+
45+
46+
@Deprecated
47+
Program() {
48+
}
49+
50+
51+
@Override
52+
public boolean equals(Object o) {
53+
if (o == null || getClass() != o.getClass()) {
54+
return false;
55+
}
56+
Program program = (Program) o;
57+
return Objects.equals(name, program.name);
58+
}
59+
60+
@Override
61+
public int hashCode() {
62+
return Objects.hashCode(name);
63+
}
64+
65+
@Override
66+
public String toString() {
67+
return "Program{" +
68+
"name='" + name + '\'' +
69+
", socialMedia=" + socialMedia +
70+
'}';
71+
}
72+
}

jnosql-mongodb/src/test/java/org/eclipse/jnosql/databases/mongodb/integration/TemplateIntegrationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,9 @@ void shouldUpdateEmbeddable() {
159159
soft.assertThat(result.availableTransitions().get(0).restrictedRoleGroups().get(0)).isEqualTo("ADMIN");
160160
});
161161
}
162+
163+
@Test
164+
void shouldInsertEntityWithMap() {
165+
166+
}
162167
}

0 commit comments

Comments
 (0)