Skip to content

Commit 4e3ad76

Browse files
authored
Merge pull request #46 from oci-labs/Issue_17_unit_tests
Issue 17 unit tests
2 parents 8e51a6b + d5c9c52 commit 4e3ad76

File tree

5 files changed

+311
-12
lines changed

5 files changed

+311
-12
lines changed

server/build.gradle

+10-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ repositories {
2929
dependencyManagement {
3030
imports {
3131
mavenBom 'io.micronaut:micronaut-bom:2.0.0.M1'
32+
mavenBom 'org.junit:junit-bom:5.5.2'
3233
}
3334
}
3435

@@ -40,6 +41,7 @@ configurations {
4041
dependencies {
4142
annotationProcessor "io.micronaut:micronaut-inject-java"
4243
annotationProcessor "io.micronaut:micronaut-validation"
44+
annotationProcessor "io.micronaut.data:micronaut-data-processor:1.0.2"
4345
implementation "io.micronaut:micronaut-inject"
4446
implementation "io.micronaut:micronaut-validation"
4547
implementation "io.micronaut:micronaut-runtime"
@@ -54,17 +56,21 @@ dependencies {
5456
implementation "com.google.apis:google-api-services-gmail:v1-rev20200203-1.30.9"
5557
implementation "io.micronaut:micronaut-views"
5658
implementation "org.thymeleaf:thymeleaf:3.0.11.RELEASE"
59+
implementation "io.micronaut.configuration:micronaut-hibernate-jpa"
60+
implementation "io.micronaut.data:micronaut-data-jdbc:1.0.2"
61+
implementation "io.micronaut.configuration:micronaut-jdbc-hikari"
5762
runtime "com.h2database:h2"
5863
runtimeOnly "ch.qos.logback:logback-classic:1.2.3"
5964
runtimeOnly "org.fusesource.jansi:jansi:1.18"
6065
testAnnotationProcessor "io.micronaut:micronaut-inject-java"
66+
testCompile 'org.junit.jupiter:junit-jupiter-api'
67+
testCompile 'org.junit.jupiter:junit-jupiter-params'
68+
testCompile 'org.junit.platform:junit-platform-launcher'
69+
testCompile 'org.junit.platform:junit-platform-runner'
6170
testImplementation "org.junit.jupiter:junit-jupiter-api"
6271
testImplementation "io.micronaut.test:micronaut-test-junit5"
6372
testImplementation "org.mockito:mockito-junit-jupiter:2.22.0"
64-
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
65-
implementation "io.micronaut.configuration:micronaut-hibernate-jpa"
66-
implementation "io.micronaut.data:micronaut-data-jdbc:1.0.2"
67-
implementation "io.micronaut.configuration:micronaut-jdbc-hikari"
73+
testRuntime 'org.junit.jupiter:junit-jupiter-engine'
6874
}
6975

7076
test.classpath += configurations.developmentOnly

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfile.java

+15-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55

66
import javax.persistence.Column;
77
import javax.persistence.Entity;
8-
98
import javax.persistence.GeneratedValue;
109
import javax.persistence.Id;
1110
import javax.persistence.Table;
1211
import javax.validation.constraints.NotNull;
1312

13+
import org.hibernate.annotations.ColumnDefault;
14+
import org.hibernate.annotations.GenericGenerator;
15+
import org.hibernate.annotations.Type;
16+
1417
@Entity
1518
@Table(name ="member_profile")
1619
public class MemberProfile {
@@ -28,9 +31,15 @@ public MemberProfile(String name, String role, UUID pdlId, String location,
2831
this.bioText=bioText;
2932
}
3033

31-
@Id
32-
@Column(name="uuid")
33-
@GeneratedValue
34+
public MemberProfile() {
35+
}
36+
37+
@Id
38+
@Type(type = "uuid-char")
39+
@Column(name="uuid", updatable = false, nullable = false, unique = true)
40+
@GeneratedValue(generator = "UUID")
41+
@GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
42+
@ColumnDefault("random_uuid()")
3443
private UUID uuid;
3544

3645
@NotNull
@@ -39,7 +48,8 @@ public MemberProfile(String name, String role, UUID pdlId, String location,
3948

4049
@Column(name="role")
4150
private String role ;
42-
51+
52+
@Type(type = "uuid-char")
4353
@Column(name="pdlId")
4454
private UUID pdlId;
4555

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileController.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
import javax.annotation.Nullable;
88
import javax.validation.Valid;
99

10-
import com.objectcomputing.checkins.services.memberprofile.MemberProfile;
11-
1210
import io.micronaut.http.HttpResponse;
11+
import io.micronaut.http.MediaType;
1312
import io.micronaut.http.annotation.Body;
1413
import io.micronaut.http.annotation.Controller;
1514
import io.micronaut.http.annotation.Get;
1615
import io.micronaut.http.annotation.Post;
1716
import io.micronaut.http.annotation.Put;
17+
import io.micronaut.http.annotation.Produces;
1818

19-
@Controller("/team-profile")
19+
@Controller("/member-profile")
20+
@Produces(MediaType.APPLICATION_JSON)
2021
public class MemberProfileController {
2122

2223
protected final MemberProfileRepository memberProfileRepository;

server/src/main/java/com/objectcomputing/checkins/services/memberprofile/MemberProfileRepository.java

+4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66
import com.objectcomputing.checkins.services.memberprofile.MemberProfile;
77

8+
import io.micronaut.data.jdbc.annotation.JdbcRepository;
89
import io.micronaut.data.repository.CrudRepository;
910

11+
import io.micronaut.data.model.query.builder.sql.Dialect;
12+
13+
@JdbcRepository(dialect = Dialect.H2)
1014
public interface MemberProfileRepository extends CrudRepository<MemberProfile, UUID> {
1115
List<MemberProfile> findByName(String name);
1216
List<MemberProfile> findByRole(String name);

0 commit comments

Comments
 (0)