| | |
| | | import static org.mockito.Mockito.verify; |
| | | import static org.mockito.Mockito.when; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.MybatisConfiguration; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.TableInfoHelper; |
| | | import com.talentcard.server.entity.DependentCardApply; |
| | | import com.talentcard.server.entity.DependentCardApplyStatusLog; |
| | | import com.talentcard.server.mapper.DependentCardApplyMapper; |
| | |
| | | import org.junit.jupiter.api.BeforeEach; |
| | | import org.junit.jupiter.api.Test; |
| | | import org.junit.jupiter.api.extension.ExtendWith; |
| | | import org.apache.ibatis.builder.MapperBuilderAssistant; |
| | | import org.mockito.ArgumentCaptor; |
| | | import org.mockito.Mock; |
| | | import org.mockito.junit.jupiter.MockitoExtension; |
| | |
| | | |
| | | @BeforeEach |
| | | void setUp() { |
| | | TableInfoHelper.initTableInfo( |
| | | new MapperBuilderAssistant(new MybatisConfiguration(), "dependent-card-test"), |
| | | DependentCardApply.class |
| | | ); |
| | | service = new DependentCardApplyService(mapper, statusLogMapper); |
| | | } |
| | | |
| | | @Test |
| | | void listExcludesCancelledFamilyCards() { |
| | | when(mapper.selectList(any(Wrapper.class))).thenReturn(List.of()); |
| | | |
| | | service.list(34L); |
| | | |
| | | ArgumentCaptor<LambdaQueryWrapper<DependentCardApply>> queryCaptor = ArgumentCaptor.forClass(LambdaQueryWrapper.class); |
| | | verify(mapper).selectList(queryCaptor.capture()); |
| | | LambdaQueryWrapper<DependentCardApply> query = queryCaptor.getValue(); |
| | | assertThat(query.getSqlSegment()).contains("talent_card_id", "status <>"); |
| | | assertThat(query.getParamNameValuePairs()).containsValue(34L).containsValue(DependentCardApply.STATUS_CANCELLED); |
| | | } |
| | | |
| | | @Test |
| | | void resubmitCreatesANewApplicationAndKeepsRejectedApplicationUnchanged() { |
| | | DependentCardApply rejected = new DependentCardApply( |
| | | "DCA-OLD", |