test: add architecture and OpenAPI validation tooling
This commit is contained in:
@@ -25,10 +25,11 @@ test('customer statistics remains an independently packaged low-coupling slice',
|
||||
const report = analyze();
|
||||
const classes = report.classes.filter(entry => entry.slice === 'customer-statistics');
|
||||
assert.deepEqual(classes.map(entry => entry.fqcn).sort(), [
|
||||
'com.baiyue.firstleg.customerstatistics.controller.PlatformCustomerTransitStatisticsController',
|
||||
'com.baiyue.firstleg.customerstatistics.dto.CustomerTransitStatisticsDtos',
|
||||
'com.baiyue.firstleg.customerstatistics.mapper.CustomerTransitStatisticsMapper',
|
||||
'com.baiyue.firstleg.customerstatistics.service.CustomerTransitStatisticsService',
|
||||
'com.baiyue.firstleg.customerstatistics.adapter.in.web.PlatformCustomerTransitStatisticsController',
|
||||
'com.baiyue.firstleg.customerstatistics.adapter.out.persistence.CustomerTransitStatisticsMapper',
|
||||
'com.baiyue.firstleg.customerstatistics.application.CustomerTransitStatisticsService',
|
||||
'com.baiyue.firstleg.customerstatistics.application.model.CustomerTransitStatisticsDtos',
|
||||
'com.baiyue.firstleg.customerstatistics.application.port.out.CustomerTransitStatisticsReader',
|
||||
]);
|
||||
const outgoing = report.sliceEdges.filter(edge => edge.source === 'customer-statistics');
|
||||
const incoming = report.sliceEdges.filter(edge => edge.target === 'customer-statistics');
|
||||
@@ -37,3 +38,17 @@ test('customer statistics remains an independently packaged low-coupling slice',
|
||||
assert.equal(report.sliceSccs.some(component => component.includes('customer-statistics')), false);
|
||||
});
|
||||
|
||||
test('customer statistics application layer only depends inward', () => {
|
||||
const report = analyze();
|
||||
const prefix = 'com.baiyue.firstleg.customerstatistics.application';
|
||||
const applicationClasses = report.classes.filter(entry => entry.packageName.startsWith(prefix));
|
||||
assert.equal(applicationClasses.length, 3);
|
||||
for (const entry of applicationClasses) {
|
||||
assert.equal(entry.imports.some(imported => imported.startsWith('org.springframework.web')), false);
|
||||
assert.equal(entry.imports.some(imported => imported.startsWith('org.apache.ibatis')), false);
|
||||
assert.equal(entry.imports.some(imported => imported.startsWith('com.baomidou.mybatisplus')), false);
|
||||
}
|
||||
const outwardDependencies = report.classDependencies.filter(edge => edge.source.startsWith(prefix)
|
||||
&& edge.target.startsWith('com.baiyue.firstleg.') && !edge.target.startsWith(prefix));
|
||||
assert.deepEqual(outwardDependencies, []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user