Skip to content

Commit

Permalink
Testing, testing
Browse files Browse the repository at this point in the history
  • Loading branch information
MichiBaum committed Oct 1, 2024
1 parent 2074a9f commit 2539a2e
Show file tree
Hide file tree
Showing 21 changed files with 299 additions and 36 deletions.
19 changes: 19 additions & 0 deletions .run/All UT.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="All UT" type="JUnit" factoryName="JUnit">
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="ALTERNATIVE_JRE_PATH" value="openjdk-21" />
<option name="PACKAGE_NAME" value="com.michibaum" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="pattern" />
<option name="TEST_SEARCH_SCOPE">
<value defaultName="wholeProject" />
</option>
<patterns>
<pattern testClass="^(.*UT$).*$" />
</patterns>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
4 changes: 4 additions & 0 deletions admin-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>

<!-- Cluster replication -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.michibaum.admin_service

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.ApplicationContext


@SpringBootTest
class AdminServiceApplicationIT {

@Autowired
lateinit var applicationContext: ApplicationContext

@Test
fun contextLoads() {
assertNotNull(applicationContext)
}
}
2 changes: 1 addition & 1 deletion authentication-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spring:
url: jdbc:mysql://authentication-db:3306/${DATABASE}
jpa:
hibernate:
dll-auto: update
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.michibaum.authentication_service

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.ApplicationContext

@SpringBootTest
class AuthenticationServiceApplicationIT {

@Autowired
lateinit var applicationContext: ApplicationContext

@Test
fun contextLoads() {
assertNotNull(applicationContext)
}
}
4 changes: 2 additions & 2 deletions authentication-service/src/test/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ spring:
url: jdbc:h2:mem:authentication-db
jpa:
hibernate:
dll-auto: create
ddl-auto: create-drop
properties:
hibernate:
dialect: org.hibernate.dialect.H2Dialect
globally_quoted_identifiers: true

eureka:
instance:
Expand Down
4 changes: 4 additions & 0 deletions gateway-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.michibaum.gatewayservice

import feign.codec.Decoder
import feign.codec.Encoder
import org.springframework.beans.factory.ObjectFactory
import org.springframework.boot.autoconfigure.http.HttpMessageConverters
import org.springframework.cloud.openfeign.support.SpringDecoder
import org.springframework.cloud.openfeign.support.SpringEncoder
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

/**
* https://github.com/spring-cloud/spring-cloud-openfeign/issues/235
* fanticat opened this issue on Oct 22, 2019 · 10 comments
*/
@Configuration
class FeignResponseCoderConfig {

private val messageConverters = ObjectFactory { HttpMessageConverters() }

@Bean
fun feignEncoder(): Encoder {
return SpringEncoder(messageConverters)
}

@Bean
fun feignDecoder(): Decoder {
return SpringDecoder(messageConverters)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.michibaum.gatewayservice

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.ApplicationContext

@SpringBootTest
class GatewayServiceApplicationIT {

@Autowired
lateinit var applicationContext: ApplicationContext

@Test
fun contextLoads() {
assertNotNull(applicationContext)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.michibaum.javadoc_service

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.ApplicationContext

@SpringBootTest
class JavadocServiceApplicationIT {

@Autowired
lateinit var applicationContext: ApplicationContext

@Test
fun contextLoads() {
assertNotNull(applicationContext)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.michibaum.registry_service

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.ApplicationContext

@SpringBootTest
class RegistryServiceApplicationIT {

@Autowired
lateinit var applicationContext: ApplicationContext

@Test
fun contextLoads() {
assertNotNull(applicationContext)
}
}
5 changes: 5 additions & 0 deletions usermanagement-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
<version>${mockk.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ data class User (
@Column(nullable = false)
val password: String
) {
constructor() : this(UUID.randomUUID(), "", "", "") {
constructor() : this(id = UUID.randomUUID(), username = "", email = "", password = "") {

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.michibaum.usermanagement_service

import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository

@Repository
interface UserRepository : JpaRepository<User, String> {

}
2 changes: 1 addition & 1 deletion usermanagement-service/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spring:
url: jdbc:mysql://usermanagement-db:3306/${DATABASE}
jpa:
hibernate:
dll-auto: update
ddl-auto: update
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialect
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.michibaum.usermanagement_service

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest

@DataJpaTest
class UserRepositoryIT {

@Autowired
private lateinit var userRepository: UserRepository

@Test
fun `find with no database content`(){
// GIVEN


// WHEN
var result = userRepository.findAll()

// THEN
assertEquals(0, result.size)

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.michibaum.usermanagement_service

import org.junit.jupiter.api.Assertions.*

class UserServiceUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.michibaum.usermanagement_service

import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.context.ApplicationContext

@SpringBootTest
class UsermanagementServiceApplicationIT {

@Autowired
lateinit var applicationContext: ApplicationContext

@Test
fun contextLoads() {
assertNotNull(applicationContext)
}
}
64 changes: 64 additions & 0 deletions usermanagement-service/src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
server:
shutdown: graceful
undertow:
url-charset: UTF-8

spring:
threads:
virtual:
enabled: true
lifecycle:
timeout-per-shutdown-phase: 20s
application:
name: usermanagement-service
cloud:
discovery:
client:
health-indicator:
include-description: true
main:
allow-bean-definition-overriding: true
datasource:
username: sa
password: password
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:usermanagement-db
jpa:
hibernate:
ddl-auto: create-drop
properties:
hibernate:
globally_quoted_identifiers: true

eureka:
instance:
prefer-ip-address: true
client:
enabled: true
fetch-registry: true
register-with-eureka: true
refresh:
enable: true

management:
endpoints:
enabled-by-default: true
web:
exposure:
include: "*"
endpoint:
env:
post:
enabled: true
health:
show-details: always
probes:
enabled: true
health:
livenessstate:
enabled: true
readinessstate:
enabled: true
info:
git:
mode: full
Loading

0 comments on commit 2539a2e

Please sign in to comment.