blob: 93b366c8d0888357c7aaa3352b74336fa52cc0c9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.derived;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.searchdefinition.parser.ParseException;
import com.yahoo.searchlib.rankingexpression.integration.ml.importer.ImportedModels;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
/**
* Tests really simple inheriting
*/
public class SimpleInheritTestCase extends AbstractExportingTestCase {
@Test
public void testEmptyChild() throws IOException, ParseException {
String name = "emptychild";
final String expectedResultsDirName = "src/test/derived/" + name + "/";
SearchBuilder builder = new SearchBuilder();
builder.importFile(expectedResultsDirName + "parent.sd");
builder.importFile(expectedResultsDirName + "child.sd");
builder.build();
Search search = builder.getSearch("child");
String toDirName = "temp/" + name;
File toDir = new File(toDirName);
toDir.mkdirs();
deleteContent(toDir);
DerivedConfiguration config = new DerivedConfiguration(search,
builder.getRankProfileRegistry(),
new QueryProfileRegistry(),
new ImportedModels());
config.export(toDirName);
checkDir(toDirName, expectedResultsDirName);
}
private void checkDir(String toDirName, String expectedResultsDirName) throws IOException {
File[] files = new File(expectedResultsDirName).listFiles();
for (File file : files) {
if (!file.getName().endsWith(".cfg")) {
continue;
}
assertEqualFiles(file.getPath(), toDirName + "/" + file.getName());
}
}
}
|