|
|
|
@ -6,6 +6,7 @@ import com.yau.digitalrmb.platformintegration.domain.PlatformRole;
|
|
|
|
import org.h2.jdbcx.JdbcDataSource;
|
|
|
|
import org.h2.jdbcx.JdbcDataSource;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
|
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
|
|
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
import javax.sql.DataSource;
|
|
|
|
@ -14,6 +15,7 @@ import java.sql.Statement;
|
|
|
|
import java.time.Instant;
|
|
|
|
import java.time.Instant;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
|
|
|
|
|
|
|
|
|
|
class JdbcPlatformIdentityRepositoryTest {
|
|
|
|
class JdbcPlatformIdentityRepositoryTest {
|
|
|
|
private DataSource dataSource;
|
|
|
|
private DataSource dataSource;
|
|
|
|
@ -54,6 +56,17 @@ class JdbcPlatformIdentityRepositoryTest {
|
|
|
|
assertThat(repository.findByPlatformUserId(202L)).isEmpty();
|
|
|
|
assertThat(repository.findByPlatformUserId(202L)).isEmpty();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
void rejectsDuplicateSchoolAccounts() throws Exception {
|
|
|
|
|
|
|
|
execute("INSERT INTO core_user(ID, CODE, NAME, STATE, JOB_TYPE1, DEL_FLAG) VALUES (301, 'duplicate', 'student one', 'S1', 'JT_S_03', 0)");
|
|
|
|
|
|
|
|
execute("INSERT INTO core_user(ID, CODE, NAME, STATE, JOB_TYPE1, DEL_FLAG) VALUES (302, 'duplicate', 'student two', 'S1', 'JT_S_03', 0)");
|
|
|
|
|
|
|
|
execute("INSERT INTO student(student_id, user_id, student_status, add_time) VALUES (11, 301, 1, '2026-01-01 00:00:00')");
|
|
|
|
|
|
|
|
execute("INSERT INTO student(student_id, user_id, student_status, add_time) VALUES (12, 302, 1, '2026-01-01 00:00:00')");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertThatThrownBy(() -> repository.findBySchoolAccount("duplicate"))
|
|
|
|
|
|
|
|
.isInstanceOf(IncorrectResultSizeDataAccessException.class);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
private void createSchema() throws Exception {
|
|
|
|
private void createSchema() throws Exception {
|
|
|
|
execute("CREATE TABLE core_user(ID BIGINT PRIMARY KEY, CODE VARCHAR(64), NAME VARCHAR(64), STATE VARCHAR(16), JOB_TYPE1 VARCHAR(16), DEL_FLAG INT)");
|
|
|
|
execute("CREATE TABLE core_user(ID BIGINT PRIMARY KEY, CODE VARCHAR(64), NAME VARCHAR(64), STATE VARCHAR(16), JOB_TYPE1 VARCHAR(16), DEL_FLAG INT)");
|
|
|
|
|