Updated regex and added about 200.000 validation rows
This commit is contained in:
parent
26bc2e2128
commit
ffb9220fb2
|
@ -87,6 +87,7 @@ public class TestRules extends ContextTest {
|
|||
final String requiredMatchesFileName = rulesFile.getName().replaceAll(".json", ".csv");
|
||||
File elaborationFile = new File(rulesDirectory, requiredMatchesFileName);
|
||||
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFile))) {
|
||||
int lineNumber = 1;
|
||||
for(String line; (line = br.readLine()) != null;) {
|
||||
String[] splittedLine = line.split(",");
|
||||
|
||||
|
@ -96,10 +97,10 @@ public class TestRules extends ContextTest {
|
|||
|
||||
Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
|
||||
if(replace != null) {
|
||||
logger.info("{} --> {},{},{}", line, replace.getServiceClass(), replace.getServiceName(),
|
||||
logger.info("line {}: {} --> {},{},{}", lineNumber, line, replace.getServiceClass(), replace.getServiceName(),
|
||||
replace.getCalledMethod());
|
||||
} else {
|
||||
logger.error("{} does not match {}. This MUST not occur.", line,
|
||||
logger.error("{} (line {}) does not match {}. This MUST not occur.", line, lineNumber,
|
||||
matcherReplace.getMultiMatcher().toString());
|
||||
throw new Exception();
|
||||
}
|
||||
|
@ -157,6 +158,8 @@ public class TestRules extends ContextTest {
|
|||
Assert.assertTrue(aggregated.getMaxInvocationTime() == surDuration);
|
||||
}
|
||||
|
||||
++lineNumber;
|
||||
|
||||
}
|
||||
} catch(Exception e) {
|
||||
throw e;
|
||||
|
@ -173,35 +176,42 @@ public class TestRules extends ContextTest {
|
|||
for(File elaborationFileNoMatch : rulesDirectory.listFiles(filenameFilter)) {
|
||||
logger.info("Comparing examples which must not match from file {}", elaborationFileNoMatch.getName());
|
||||
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFileNoMatch))) {
|
||||
int lineCounter = 1;
|
||||
for(String line; (line = br.readLine()) != null;) {
|
||||
String[] splittedLine = line.split(",");
|
||||
String serviceClass = splittedLine[0];
|
||||
String serviceName = splittedLine[1];
|
||||
String calledMethod = splittedLine[2];
|
||||
Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
|
||||
if(replace != null) {
|
||||
logger.error("{} match {} but it should NOT. This MUST not occur.", line,
|
||||
matcherReplace.getMultiMatcher().toString());
|
||||
throw new Exception();
|
||||
} else {
|
||||
logger.trace("{} does NOT match as requested", line, replacementRegex.getServiceClass(),
|
||||
replacementRegex.getServiceName(), replacementRegex.getCalledMethod());
|
||||
}
|
||||
|
||||
ServiceUsageRecord sur = TestUsageRecord.createTestServiceUsageRecord();
|
||||
sur.setServiceClass(serviceClass);
|
||||
sur.setServiceName(serviceName);
|
||||
sur.setCalledMethod(calledMethod);
|
||||
sur.validate();
|
||||
//logger.trace("Should not be aggregated ServiceUsageRecord {}", sur);
|
||||
for(AggregatedServiceUsageRecord asur : aggregatedMap.values()) {
|
||||
try {
|
||||
asur.aggregate(sur);
|
||||
logger.error("The record {} has been aggregated and it should NOT", sur);
|
||||
throw new Exception("The record has been aggregated and it should NOT");
|
||||
} catch(NotAggregatableRecordsExceptions e) {
|
||||
//logger.trace("{} is not aggragable as expected", sur);
|
||||
try {
|
||||
String[] splittedLine = line.split(",");
|
||||
String serviceClass = splittedLine[0];
|
||||
String serviceName = splittedLine[1];
|
||||
String calledMethod = splittedLine[2];
|
||||
Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
|
||||
if(replace != null) {
|
||||
logger.error("{} match {} but it should NOT. This MUST not occur.", line,
|
||||
matcherReplace.getMultiMatcher().toString());
|
||||
throw new Exception();
|
||||
} else {
|
||||
logger.trace("{} does NOT match as requested", line, replacementRegex.getServiceClass(),
|
||||
replacementRegex.getServiceName(), replacementRegex.getCalledMethod());
|
||||
}
|
||||
|
||||
ServiceUsageRecord sur = TestUsageRecord.createTestServiceUsageRecord();
|
||||
sur.setServiceClass(serviceClass);
|
||||
sur.setServiceName(serviceName);
|
||||
sur.setCalledMethod(calledMethod);
|
||||
sur.validate();
|
||||
//logger.trace("Should not be aggregated ServiceUsageRecord {}", sur);
|
||||
for(AggregatedServiceUsageRecord asur : aggregatedMap.values()) {
|
||||
try {
|
||||
asur.aggregate(sur);
|
||||
logger.error("The record {} (line {}) has been aggregated and it should NOT", sur, lineCounter);
|
||||
throw new Exception("The record has been aggregated and it should NOT");
|
||||
} catch(NotAggregatableRecordsExceptions e) {
|
||||
//logger.trace("{} is not aggragable as expected", sur);
|
||||
}
|
||||
}
|
||||
++lineCounter;
|
||||
}catch (Exception e) {
|
||||
logger.error("line {}", lineCounter, e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
|
@ -227,7 +237,7 @@ public class TestRules extends ContextTest {
|
|||
public void testAllRuleInAdirectory() throws Exception {
|
||||
allRules();
|
||||
File rulesDirectory = getRulesDirectory();
|
||||
File rulesDirFile = new File(rulesDirectory, "perform-service");
|
||||
File rulesDirFile = new File(rulesDirectory, "Thredds");
|
||||
|
||||
FilenameFilter filenameFilter = new FilenameFilter() {
|
||||
@Override
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
|||
"match": {
|
||||
"serviceClassRegex": "SDI|DataAnalysis",
|
||||
"serviceNameRegex": "Thredds",
|
||||
"calledMethodRegex": "^(\/){1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}(?<Collection>[a-zA-Z0-9_\\-%]*(?<!(..\\.nc)))(\/){1}.*(?<!(..\\.nc|.\\.asc|\\.tiff))$"
|
||||
"calledMethodRegex": "^(\/){1}(thredds\/){0,1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}(?<Collection>[a-zA-Z0-9_\\-%]*(?<!(..\\.nc)))(\/){1}.*(?<!(..\\.nc|.\\.asc|\\.tiff))$"
|
||||
},
|
||||
"replace": {
|
||||
"serviceClass": "SDI",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
|||
"match": {
|
||||
"serviceClassRegex": "SDI|DataAnalysis",
|
||||
"serviceNameRegex": "Thredds",
|
||||
"calledMethodRegex": "^(\/){1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}[^\/]*((?<!(..\\.nc|.\\.asc|\\.tiff))|\/wfs)$"
|
||||
"calledMethodRegex": "^(\/){1}(thredds\/){0,1}(?<Protocol>[a-zA-Z0-9]*){1}(\/grid){0,1}(\/public\/netcdf\/){1}[^\/]*((?<!(..\\.nc|.\\.asc|\\.tiff))|((\/wfs)|(\/(pointD|d)ataset\\.(html|xml))))$"
|
||||
},
|
||||
"replace": {
|
||||
"serviceClass": "SDI",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
|||
"match": {
|
||||
"serviceClassRegex": "SDI|DataAnalysis",
|
||||
"serviceNameRegex": "Thredds",
|
||||
"calledMethodRegex": "^(\/){1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}(?<Collection>[a-zA-Z0-9_\\-%]*)(\/){1}(.*\\.(nc|asc|tiff))$"
|
||||
"calledMethodRegex": "^(\/){1}(thredds\/){0,1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}(?<Collection>[a-zA-Z0-9_\\-%]*)(\/){1}(.*\\.(nc|asc|tiff))$"
|
||||
},
|
||||
"replace": {
|
||||
"serviceClass": "SDI",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
|||
"match": {
|
||||
"serviceClassRegex": "SDI|DataAnalysis",
|
||||
"serviceNameRegex": "Thredds",
|
||||
"calledMethodRegex": "^(\/){1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}[^\/]*(\\.(nc|asc|tiff))$"
|
||||
"calledMethodRegex": "^(\/){1}(thredds\/){0,1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}[^\/]*(\\.(nc|asc|tiff))$"
|
||||
},
|
||||
"replace": {
|
||||
"serviceClass": "SDI",
|
||||
|
|
Loading…
Reference in New Issue