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");
|
final String requiredMatchesFileName = rulesFile.getName().replaceAll(".json", ".csv");
|
||||||
File elaborationFile = new File(rulesDirectory, requiredMatchesFileName);
|
File elaborationFile = new File(rulesDirectory, requiredMatchesFileName);
|
||||||
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFile))) {
|
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFile))) {
|
||||||
|
int lineNumber = 1;
|
||||||
for(String line; (line = br.readLine()) != null;) {
|
for(String line; (line = br.readLine()) != null;) {
|
||||||
String[] splittedLine = line.split(",");
|
String[] splittedLine = line.split(",");
|
||||||
|
|
||||||
|
@ -96,10 +97,10 @@ public class TestRules extends ContextTest {
|
||||||
|
|
||||||
Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
|
Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
|
||||||
if(replace != null) {
|
if(replace != null) {
|
||||||
logger.info("{} --> {},{},{}", line, replace.getServiceClass(), replace.getServiceName(),
|
logger.info("line {}: {} --> {},{},{}", lineNumber, line, replace.getServiceClass(), replace.getServiceName(),
|
||||||
replace.getCalledMethod());
|
replace.getCalledMethod());
|
||||||
} else {
|
} 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());
|
matcherReplace.getMultiMatcher().toString());
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
@ -157,6 +158,8 @@ public class TestRules extends ContextTest {
|
||||||
Assert.assertTrue(aggregated.getMaxInvocationTime() == surDuration);
|
Assert.assertTrue(aggregated.getMaxInvocationTime() == surDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++lineNumber;
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -173,35 +176,42 @@ public class TestRules extends ContextTest {
|
||||||
for(File elaborationFileNoMatch : rulesDirectory.listFiles(filenameFilter)) {
|
for(File elaborationFileNoMatch : rulesDirectory.listFiles(filenameFilter)) {
|
||||||
logger.info("Comparing examples which must not match from file {}", elaborationFileNoMatch.getName());
|
logger.info("Comparing examples which must not match from file {}", elaborationFileNoMatch.getName());
|
||||||
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFileNoMatch))) {
|
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFileNoMatch))) {
|
||||||
|
int lineCounter = 1;
|
||||||
for(String line; (line = br.readLine()) != null;) {
|
for(String line; (line = br.readLine()) != null;) {
|
||||||
String[] splittedLine = line.split(",");
|
try {
|
||||||
String serviceClass = splittedLine[0];
|
String[] splittedLine = line.split(",");
|
||||||
String serviceName = splittedLine[1];
|
String serviceClass = splittedLine[0];
|
||||||
String calledMethod = splittedLine[2];
|
String serviceName = splittedLine[1];
|
||||||
Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
|
String calledMethod = splittedLine[2];
|
||||||
if(replace != null) {
|
Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
|
||||||
logger.error("{} match {} but it should NOT. This MUST not occur.", line,
|
if(replace != null) {
|
||||||
matcherReplace.getMultiMatcher().toString());
|
logger.error("{} match {} but it should NOT. This MUST not occur.", line,
|
||||||
throw new Exception();
|
matcherReplace.getMultiMatcher().toString());
|
||||||
} else {
|
throw new Exception();
|
||||||
logger.trace("{} does NOT match as requested", line, replacementRegex.getServiceClass(),
|
} else {
|
||||||
replacementRegex.getServiceName(), replacementRegex.getCalledMethod());
|
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
} catch(Exception e) {
|
||||||
|
@ -227,7 +237,7 @@ public class TestRules extends ContextTest {
|
||||||
public void testAllRuleInAdirectory() throws Exception {
|
public void testAllRuleInAdirectory() throws Exception {
|
||||||
allRules();
|
allRules();
|
||||||
File rulesDirectory = getRulesDirectory();
|
File rulesDirectory = getRulesDirectory();
|
||||||
File rulesDirFile = new File(rulesDirectory, "perform-service");
|
File rulesDirFile = new File(rulesDirectory, "Thredds");
|
||||||
|
|
||||||
FilenameFilter filenameFilter = new FilenameFilter() {
|
FilenameFilter filenameFilter = new FilenameFilter() {
|
||||||
@Override
|
@Override
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
||||||
"match": {
|
"match": {
|
||||||
"serviceClassRegex": "SDI|DataAnalysis",
|
"serviceClassRegex": "SDI|DataAnalysis",
|
||||||
"serviceNameRegex": "Thredds",
|
"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": {
|
"replace": {
|
||||||
"serviceClass": "SDI",
|
"serviceClass": "SDI",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
||||||
"match": {
|
"match": {
|
||||||
"serviceClassRegex": "SDI|DataAnalysis",
|
"serviceClassRegex": "SDI|DataAnalysis",
|
||||||
"serviceNameRegex": "Thredds",
|
"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": {
|
"replace": {
|
||||||
"serviceClass": "SDI",
|
"serviceClass": "SDI",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
||||||
"match": {
|
"match": {
|
||||||
"serviceClassRegex": "SDI|DataAnalysis",
|
"serviceClassRegex": "SDI|DataAnalysis",
|
||||||
"serviceNameRegex": "Thredds",
|
"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": {
|
"replace": {
|
||||||
"serviceClass": "SDI",
|
"serviceClass": "SDI",
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
||||||
"match": {
|
"match": {
|
||||||
"serviceClassRegex": "SDI|DataAnalysis",
|
"serviceClassRegex": "SDI|DataAnalysis",
|
||||||
"serviceNameRegex": "Thredds",
|
"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": {
|
"replace": {
|
||||||
"serviceClass": "SDI",
|
"serviceClass": "SDI",
|
||||||
|
|
Loading…
Reference in New Issue