mirror of
https://github.com/vran-dev/databasir.git
synced 2025-11-05 17:06:12 +08:00
refactor: rename pojo class name (#225)
* refactor: rename pojo class name * fix: compile error
This commit is contained in:
@@ -8,7 +8,7 @@ import com.databasir.core.domain.database.data.DatabaseTypeUpdateRequest;
|
||||
import com.databasir.core.infrastructure.driver.DriverResources;
|
||||
import com.databasir.core.infrastructure.driver.DriverResult;
|
||||
import com.databasir.dao.impl.DatabaseTypeDao;
|
||||
import com.databasir.dao.tables.pojos.DatabaseTypePojo;
|
||||
import com.databasir.dao.tables.pojos.DatabaseType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -87,7 +87,7 @@ class DatabaseTypeServiceTest extends BaseTest {
|
||||
request.setUrlPattern("{{jdbc.protocol}}//{{db.url}}/{{db.schema}}");
|
||||
databaseTypeService.update(request);
|
||||
|
||||
DatabaseTypePojo pojo = databaseTypeDao.selectByDatabaseType("new-type");
|
||||
DatabaseType pojo = databaseTypeDao.selectByDatabaseType("new-type");
|
||||
Assertions.assertNotNull(pojo);
|
||||
Assertions.assertEquals("integration test", pojo.getDescription());
|
||||
Assertions.assertEquals("jdbc:postgresql", pojo.getJdbcProtocol());
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.databasir.core.domain.description.service;
|
||||
import com.databasir.core.BaseTest;
|
||||
import com.databasir.core.domain.description.data.DocumentDescriptionSaveRequest;
|
||||
import com.databasir.dao.impl.DocumentDescriptionDao;
|
||||
import com.databasir.dao.tables.pojos.DocumentDescriptionPojo;
|
||||
import com.databasir.dao.tables.pojos.DocumentDescription;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -42,7 +42,7 @@ class DocumentDescriptionServiceTest extends BaseTest {
|
||||
documentDescriptionService.save(groupId, projectId, userId, updateRequest);
|
||||
var tableData = documentDescriptionDao.selectTableDescriptionByProjectId(projectId);
|
||||
Assertions.assertEquals(0, tableData.size());
|
||||
List<DocumentDescriptionPojo> descriptionData = documentDescriptionDao.selectByProjectId(projectId);
|
||||
List<DocumentDescription> descriptionData = documentDescriptionDao.selectByProjectId(projectId);
|
||||
Assertions.assertEquals(1, descriptionData.size());
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,8 @@ import com.databasir.dao.impl.GroupDao;
|
||||
import com.databasir.dao.impl.ProjectDao;
|
||||
import com.databasir.dao.impl.ProjectSyncRuleDao;
|
||||
import com.databasir.dao.impl.UserRoleDao;
|
||||
import com.databasir.dao.tables.pojos.ProjectSyncRulePojo;
|
||||
import com.databasir.dao.tables.pojos.UserRolePojo;
|
||||
import com.databasir.dao.tables.pojos.ProjectSyncRule;
|
||||
import com.databasir.dao.tables.pojos.UserRole;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.jdbc.Sql;
|
||||
@@ -53,7 +53,7 @@ class GroupServiceTest extends BaseTest {
|
||||
Integer groupId = groupService.create(request);
|
||||
assertNotNull(groupId);
|
||||
|
||||
List<UserRolePojo> roles = userRoleDao.selectByUserIds(List.of(1, 2, 3))
|
||||
List<UserRole> roles = userRoleDao.selectByUserIds(List.of(1, 2, 3))
|
||||
.stream()
|
||||
.filter(r -> Objects.equals(r.getGroupId(), groupId) && r.getRole().equals("GROUP_OWNER"))
|
||||
.collect(Collectors.toList());
|
||||
@@ -71,11 +71,11 @@ class GroupServiceTest extends BaseTest {
|
||||
request.setGroupOwnerUserIds(List.of(1000, 1001));
|
||||
groupService.update(request);
|
||||
|
||||
List<UserRolePojo> members = userRoleDao.selectList(Tables.USER_ROLE.GROUP_ID.eq(groupId));
|
||||
List<UserRole> members = userRoleDao.selectList(Tables.USER_ROLE.GROUP_ID.eq(groupId));
|
||||
assertEquals(3, members.size());
|
||||
List<Integer> ownerUserIds = members.stream()
|
||||
.filter(r -> r.getRole().equals("GROUP_OWNER"))
|
||||
.map(UserRolePojo::getUserId)
|
||||
.map(UserRole::getUserId)
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(2, ownerUserIds.size());
|
||||
assertTrue(ownerUserIds.contains(1000));
|
||||
@@ -95,11 +95,11 @@ class GroupServiceTest extends BaseTest {
|
||||
assertEquals(0, projectIds.size());
|
||||
|
||||
// should clear group members
|
||||
List<UserRolePojo> members = userRoleDao.selectList(Tables.USER_ROLE.GROUP_ID.eq(groupId));
|
||||
List<UserRole> members = userRoleDao.selectList(Tables.USER_ROLE.GROUP_ID.eq(groupId));
|
||||
assertEquals(0, members.size());
|
||||
|
||||
// should clear project sync schedule
|
||||
List<ProjectSyncRulePojo> syncRule = projectSyncRuleDao.selectInProjectIds(undeleteProjectIds);
|
||||
List<ProjectSyncRule> syncRule = projectSyncRuleDao.selectInProjectIds(undeleteProjectIds);
|
||||
assertTrue(syncRule.stream().allMatch(r -> !r.getIsAutoSync()));
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ class GroupServiceTest extends BaseTest {
|
||||
|
||||
groupService.changeMemberRole(groupId, userId, RoleConstants.GROUP_OWNER);
|
||||
assertTrue(userRoleDao.hasRole(userId, groupId, RoleConstants.GROUP_OWNER));
|
||||
List<UserRolePojo> roles = userRoleDao.selectByUserIds(List.of(userId));
|
||||
List<UserRole> roles = userRoleDao.selectByUserIds(List.of(userId));
|
||||
assertEquals(1, roles.size());
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import com.databasir.core.domain.login.data.AccessTokenRefreshRequest;
|
||||
import com.databasir.core.domain.login.data.AccessTokenRefreshResponse;
|
||||
import com.databasir.core.domain.login.data.LoginKeyResponse;
|
||||
import com.databasir.dao.impl.LoginDao;
|
||||
import com.databasir.dao.tables.pojos.LoginPojo;
|
||||
import com.databasir.dao.tables.pojos.Login;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -74,7 +74,7 @@ class LoginServiceTest extends BaseTest {
|
||||
int userId = -1000;
|
||||
LoginKeyResponse token = loginService.generate(userId);
|
||||
Assertions.assertNotNull(token);
|
||||
Optional<LoginPojo> loginOpt = loginDao.selectByUserId(userId);
|
||||
Optional<Login> loginOpt = loginDao.selectByUserId(userId);
|
||||
Assertions.assertTrue(loginOpt.isPresent());
|
||||
Assertions.assertEquals(token.getAccessToken(), loginOpt.get().getAccessToken());
|
||||
Assertions.assertEquals(token.getRefreshToken(), loginOpt.get().getRefreshToken());
|
||||
|
||||
@@ -11,7 +11,7 @@ import com.databasir.core.domain.project.data.ProjectUpdateRequest.ProjectSyncRu
|
||||
import com.databasir.core.infrastructure.connection.DatabaseTypes;
|
||||
import com.databasir.dao.impl.ProjectDao;
|
||||
import com.databasir.dao.impl.ProjectSyncRuleDao;
|
||||
import com.databasir.dao.tables.pojos.ProjectSyncRulePojo;
|
||||
import com.databasir.dao.tables.pojos.ProjectSyncRule;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -105,7 +105,7 @@ class ProjectServiceTest extends BaseTest {
|
||||
int projectId = -1000;
|
||||
projectService.delete(projectId);
|
||||
Assertions.assertFalse(projectDao.existsById(projectId));
|
||||
ProjectSyncRulePojo syncRule = projectSyncRuleDao.selectByProjectId(projectId);
|
||||
ProjectSyncRule syncRule = projectSyncRuleDao.selectByProjectId(projectId);
|
||||
Assertions.assertNotNull(syncRule);
|
||||
Assertions.assertNotNull(syncRule.getAutoSyncCron());
|
||||
Assertions.assertFalse(syncRule.getIsAutoSync());
|
||||
|
||||
@@ -9,9 +9,9 @@ import com.databasir.core.infrastructure.event.subscriber.UserEventSubscriber;
|
||||
import com.databasir.dao.impl.LoginDao;
|
||||
import com.databasir.dao.impl.UserDao;
|
||||
import com.databasir.dao.impl.UserRoleDao;
|
||||
import com.databasir.dao.tables.pojos.LoginPojo;
|
||||
import com.databasir.dao.tables.pojos.UserPojo;
|
||||
import com.databasir.dao.tables.pojos.UserRolePojo;
|
||||
import com.databasir.dao.tables.pojos.Login;
|
||||
import com.databasir.dao.tables.pojos.User;
|
||||
import com.databasir.dao.tables.pojos.UserRole;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
@@ -78,12 +78,12 @@ class UserServiceTest extends BaseTest {
|
||||
void switchEnableStatusToFalse() {
|
||||
Integer userId = -999;
|
||||
userService.switchEnableStatus(userId, false);
|
||||
UserPojo user = userDao.selectById(userId);
|
||||
User user = userDao.selectById(userId);
|
||||
assertNotNull(user);
|
||||
assertFalse(user.getEnabled());
|
||||
|
||||
Optional<LoginPojo> loginPojoOpt = loginDao.selectByUserId(userId);
|
||||
assertTrue(loginPojoOpt.isEmpty());
|
||||
Optional<Login> login = loginDao.selectByUserId(userId);
|
||||
assertTrue(login.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,7 +91,7 @@ class UserServiceTest extends BaseTest {
|
||||
void removeSysOwnerFrom() {
|
||||
Integer userId = -998;
|
||||
userService.removeSysOwnerFrom(userId);
|
||||
List<UserRolePojo> roles = userRoleDao.selectByUserIds(Collections.singletonList(userId))
|
||||
List<UserRole> roles = userRoleDao.selectByUserIds(Collections.singletonList(userId))
|
||||
.stream().filter(role -> role.getRole().equals(SYS_OWNER))
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(0, roles.size());
|
||||
@@ -102,7 +102,7 @@ class UserServiceTest extends BaseTest {
|
||||
void addSysOwnerTo() {
|
||||
Integer userId = -999;
|
||||
userService.addSysOwnerTo(userId);
|
||||
List<UserRolePojo> roles = userRoleDao.selectByUserIds(Collections.singletonList(userId))
|
||||
List<UserRole> roles = userRoleDao.selectByUserIds(Collections.singletonList(userId))
|
||||
.stream().filter(role -> role.getRole().equals(SYS_OWNER))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -120,8 +120,8 @@ class UserServiceTest extends BaseTest {
|
||||
Integer userId = -999;
|
||||
userService.updatePassword(userId, request);
|
||||
// should delete login info
|
||||
Optional<LoginPojo> loginPojoOpt = loginDao.selectByUserId(userId);
|
||||
assertTrue(loginPojoOpt.isEmpty());
|
||||
Optional<Login> login = loginDao.selectByUserId(userId);
|
||||
assertTrue(login.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,7 +133,7 @@ class UserServiceTest extends BaseTest {
|
||||
request.setNickname(nickname);
|
||||
userService.updateNickname(userId, request);
|
||||
|
||||
UserPojo user = userDao.selectById(userId);
|
||||
User user = userDao.selectById(userId);
|
||||
assertNotNull(user);
|
||||
assertEquals(nickname, user.getNickname());
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class DocumentEventSubscriberTest extends BaseTest {
|
||||
event.setNewVersion(2L);
|
||||
event.setOldVersion(1L);
|
||||
event.setProjectId(-1);
|
||||
documentEventSubscriber.onDocumentUpdated(event);
|
||||
documentEventSubscriber.sendMailOnUpdated(event);
|
||||
verify(mailSender, times(1)).batchSendHtml(any(), any(), any(), any());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user