http://jira.mfd.msk:8088/browse/BKI-3199 Added test for MonitoringReportErrorsStaxtReader

This commit is contained in:
Mikhail Trofimov 2025-09-11 16:38:31 +03:00
parent 0cc25b5a4b
commit 3c3e340bcd
2 changed files with 50 additions and 0 deletions

View file

@ -6,6 +6,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import ru.nbch.credit_tracker.entities.dto.PhoneFidMap;
import ru.nbch.credit_tracker.entities.external_response.monitoring_report_error.MonitoringReportErrors;
import ru.nbch.credit_tracker.entities.external_response.online_download.Person; import ru.nbch.credit_tracker.entities.external_response.online_download.Person;
import ru.nbch.credit_tracker.entities.external_response.online_download.Persons; import ru.nbch.credit_tracker.entities.external_response.online_download.Persons;
import ru.nbch.credit_tracker.entities.user_request.monitoring_request.MonitoringRequest; import ru.nbch.credit_tracker.entities.user_request.monitoring_request.MonitoringRequest;
@ -35,6 +37,7 @@ public class StaxTest {
List<Supplier<StaxReader<?>>> staxReader = new ArrayList<>(); List<Supplier<StaxReader<?>>> staxReader = new ArrayList<>();
staxReader.add(MonitoringRequestStaxReader::new); staxReader.add(MonitoringRequestStaxReader::new);
staxReader.add(OnlineDownloadReportPersonsStaxReader::new); staxReader.add(OnlineDownloadReportPersonsStaxReader::new);
staxReader.add(MonitoringReportErrorsStaxtReader::new);
return new XmlProcessorStaxImpl(staxReader); return new XmlProcessorStaxImpl(staxReader);
} }
} }
@ -150,4 +153,36 @@ public class StaxTest {
4, 4,
"/Report/Persons/Person"); "/Report/Persons/Person");
} }
@Test
void testMonitoringReportErrors() {
List<PhoneFidMap> subjects = new ArrayList<>();
staxXmlProcessor.read(getClass().getResourceAsStream("/monitoring_request/xml/report_errors.xml"), MonitoringReportErrors.class,
request -> {
if (!request.getPersons().isEmpty()) {
List<PhoneFidMap> batch = request.getPersons().stream().map(p -> {
return PhoneFidMap.builder()
.id(p.getUid())
.errorText(p.getValue())
.build();
}).toList();
subjects.addAll(batch);
request.getPersons().clear();
}
},
request -> request.getPersons().isEmpty()
,
3, "/Errors/p");
Assertions.assertEquals(4, subjects.size());
Assertions.assertEquals(97821754, subjects.get(0).getId());
Assertions.assertEquals("ERROR_TEXT_1", subjects.get(0).getErrorText());
Assertions.assertEquals(97821755, subjects.get(1).getId());
Assertions.assertEquals("ERROR_TEXT_2", subjects.get(1).getErrorText());
Assertions.assertEquals(97821756, subjects.get(2).getId());
Assertions.assertEquals("ERROR_TEXT_3", subjects.get(2).getErrorText());
Assertions.assertEquals(97821757, subjects.get(3).getId());
Assertions.assertEquals("ERROR_TEXT_4", subjects.get(3).getErrorText());
}
} }

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<Errors>
<Id>0001XX_MY_BATCH_223112</Id>
<Version>1</Version>
<User>0001ZZ000001</User>
<ReportCreated>11.09.2025 11:05:29</ReportCreated>
<p uid="97821754">ERROR_TEXT_1
</p>
<p uid="97821755">ERROR_TEXT_2
</p>
<p uid="97821756">ERROR_TEXT_3
</p>
<p uid="97821757">ERROR_TEXT_4
</p>
</Errors>