-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate performance api directory matching package
- Loading branch information
Showing
7 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...c/test/java/com/netflix/hollow/api/codegen/perfapi/HollowPerformanceAPIGeneratorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.netflix.hollow.api.codegen.perfapi; | ||
|
||
import com.netflix.hollow.api.codegen.AbstractHollowAPIGeneratorTest; | ||
import com.netflix.hollow.api.codegen.HollowCodeGenerationCompileUtil; | ||
import com.netflix.hollow.core.schema.SimpleHollowDataset; | ||
import java.io.File; | ||
import org.junit.Test; | ||
|
||
public class HollowPerformanceAPIGeneratorTest extends AbstractHollowAPIGeneratorTest { | ||
|
||
@Test | ||
public void testGeneratePerformanceApi() throws Exception { | ||
runGenerator("API", "com.netflix.hollow.example.api.performance.generated", MyClass.class); | ||
} | ||
|
||
@Test | ||
public void testGeneratedFilesArePlacedInPackageDirectory() throws Exception { | ||
runGenerator("API", "codegen.api", MyClass.class); | ||
assertNonEmptyFileExists("codegen/api/MyClassPerfAPI.java"); | ||
assertNonEmptyFileExists("codegen/api/StringPerfAPI.java"); | ||
assertNonEmptyFileExists("codegen/api/API.java"); | ||
} | ||
|
||
private void runGenerator(String apiClassName, String packageName, Class<?> clazz) throws Exception { | ||
System.out.println(String.format("Folders (%s) : \n\tsource=%s \n\tclasses=%s", | ||
getClass().getSimpleName(), sourceFolder, clazzFolder)); | ||
|
||
// Setup Folders | ||
HollowCodeGenerationCompileUtil.cleanupFolder(new File(sourceFolder), null); | ||
HollowCodeGenerationCompileUtil.cleanupFolder(new File(clazzFolder), null); | ||
|
||
// Run generator | ||
HollowPerformanceAPIGenerator generator = HollowPerformanceAPIGenerator.newBuilder() | ||
.withDestination(sourceFolder) | ||
.withPackageName(packageName) | ||
.withAPIClassname(apiClassName) | ||
.withDataset(SimpleHollowDataset.fromClassDefinitions(clazz)) | ||
.build(); | ||
generator.generateSourceFiles(); | ||
|
||
// Compile to validate generated files | ||
HollowCodeGenerationCompileUtil.compileSrcFiles(sourceFolder, clazzFolder); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
private static class MyClass { | ||
int id; | ||
String foo; | ||
|
||
public MyClass(int id, String foo) { | ||
this.id = id; | ||
this.foo = foo; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<FindBugsFilter | ||
xmlns="https://github.com/spotbugs/filter/3.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd"> | ||
|
||
<Match> | ||
<Class name="~.*\.*PerfAPI" /> | ||
<Field name="fieldNames" /> | ||
<Bug pattern="MS_PKGPROTECT" /> | ||
</Match> | ||
</FindBugsFilter> |