|
|
@@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
5
|
5
|
import static org.mockito.ArgumentMatchers.eq;
|
|
6
|
6
|
import static org.mockito.ArgumentMatchers.any;
|
|
7
|
7
|
import static org.mockito.ArgumentMatchers.anyList;
|
|
|
8
|
+import static org.mockito.Mockito.lenient;
|
|
8
|
9
|
import static org.mockito.Mockito.when;
|
|
9
|
10
|
|
|
10
|
11
|
import java.math.BigDecimal;
|
|
|
@@ -109,6 +110,37 @@ class HomeScreenServiceImplTest
|
|
109
|
110
|
assertEquals(50, vo.getMarkers().get(0).getYakOutboundCount().intValue());
|
|
110
|
111
|
}
|
|
111
|
112
|
|
|
|
113
|
+ @Test
|
|
|
114
|
+ @DisplayName("DP-SY-UT-027 产业总览存栏出栏取自填报合计")
|
|
|
115
|
+ void ut027_overviewFromReportTables()
|
|
|
116
|
+ {
|
|
|
117
|
+ int currentYear = Year.now().getValue();
|
|
|
118
|
+ stubBreedingWithOneYak();
|
|
|
119
|
+ stubOtherBlocks();
|
|
|
120
|
+ when(homeScreenStatsMapper.sumHerdInventoryYakTotalByStatYear(eq(currentYear - 1))).thenReturn(50000);
|
|
|
121
|
+ when(homeScreenStatsMapper.sumOutboundReportYakCountByStatYear(eq(currentYear))).thenReturn(3200);
|
|
|
122
|
+
|
|
|
123
|
+ HomeScreenDashboardVo vo = service.loadDashboard("2024");
|
|
|
124
|
+
|
|
|
125
|
+ assertEquals(50000, vo.getIndustryOverview().getInventoryTotal());
|
|
|
126
|
+ assertEquals(3200, vo.getIndustryOverview().getAnnualOutbound());
|
|
|
127
|
+ }
|
|
|
128
|
+
|
|
|
129
|
+ @Test
|
|
|
130
|
+ @DisplayName("DP-SY-UT-028 产业总览农牧户取自出栏填报合计")
|
|
|
131
|
+ void ut028_farmerHouseholdFromReportTable()
|
|
|
132
|
+ {
|
|
|
133
|
+ int currentYear = Year.now().getValue();
|
|
|
134
|
+ stubBreedingWithOneYak();
|
|
|
135
|
+ stubOtherBlocks();
|
|
|
136
|
+ when(homeScreenStatsMapper.sumOutboundReportFarmerHouseholdCountByStatYear(eq(currentYear)))
|
|
|
137
|
+ .thenReturn(8988);
|
|
|
138
|
+
|
|
|
139
|
+ HomeScreenDashboardVo vo = service.loadDashboard("2025");
|
|
|
140
|
+
|
|
|
141
|
+ assertEquals(8988, vo.getIndustryOverview().getPastureCount());
|
|
|
142
|
+ }
|
|
|
143
|
+
|
|
112
|
144
|
private void stubBreedingEmpty()
|
|
113
|
145
|
{
|
|
114
|
146
|
when(breedingIndustryStatsMapper.selectActivePastureIds()).thenReturn(Collections.singletonList(1L));
|
|
|
@@ -122,6 +154,11 @@ class HomeScreenServiceImplTest
|
|
122
|
154
|
when(breedingIndustryStatsMapper.selectDegradationGroupCounts()).thenReturn(Collections.emptyList());
|
|
123
|
155
|
when(homeScreenStatsMapper.selectOutboundCountByMonth(anyList(), any(), any()))
|
|
124
|
156
|
.thenReturn(Collections.emptyList());
|
|
|
157
|
+ int currentYear = Year.now().getValue();
|
|
|
158
|
+ lenient().when(homeScreenStatsMapper.sumHerdInventoryYakTotalByStatYear(eq(currentYear - 1))).thenReturn(0);
|
|
|
159
|
+ lenient().when(homeScreenStatsMapper.sumOutboundReportYakCountByStatYear(eq(currentYear))).thenReturn(0);
|
|
|
160
|
+ lenient().when(homeScreenStatsMapper.sumOutboundReportFarmerHouseholdCountByStatYear(eq(currentYear)))
|
|
|
161
|
+ .thenReturn(0);
|
|
125
|
162
|
}
|
|
126
|
163
|
|
|
127
|
164
|
private void stubBreedingWithOneYak()
|
|
|
@@ -143,6 +180,11 @@ class HomeScreenServiceImplTest
|
|
143
|
180
|
when(breedingIndustryStatsMapper.selectDegradationGroupCounts()).thenReturn(Collections.emptyList());
|
|
144
|
181
|
when(homeScreenStatsMapper.selectOutboundCountByMonth(anyList(), any(), any()))
|
|
145
|
182
|
.thenReturn(Collections.emptyList());
|
|
|
183
|
+ int currentYear = Year.now().getValue();
|
|
|
184
|
+ lenient().when(homeScreenStatsMapper.sumHerdInventoryYakTotalByStatYear(eq(currentYear - 1))).thenReturn(0);
|
|
|
185
|
+ lenient().when(homeScreenStatsMapper.sumOutboundReportYakCountByStatYear(eq(currentYear))).thenReturn(0);
|
|
|
186
|
+ lenient().when(homeScreenStatsMapper.sumOutboundReportFarmerHouseholdCountByStatYear(eq(currentYear)))
|
|
|
187
|
+ .thenReturn(0);
|
|
146
|
188
|
}
|
|
147
|
189
|
|
|
148
|
190
|
private void stubOtherBlocks()
|