-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-14724 Test generated proto schema with Infinispan API
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...t/java/org/infinispan/client/hotrod/marshall/protostream/builder/ProtoBufBuilderTest.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,54 @@ | ||
package org.infinispan.client.hotrod.marshall.protostream.builder; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.infinispan.Cache; | ||
import org.infinispan.api.protostream.builder.ProtoBuf; | ||
import org.infinispan.client.hotrod.test.SingleHotRodServerTest; | ||
import org.infinispan.commons.test.annotation.TestForIssue; | ||
import org.infinispan.query.remote.client.ProtobufMetadataManagerConstants; | ||
import org.testng.annotations.Test; | ||
|
||
@Test(groups = "functional", testName = "org.infinispan.client.hotrod.marshall.protostream.builder.ProtoBufBuilderTest") | ||
@TestForIssue(jiraKey = "ISPN-14724") | ||
public class ProtoBufBuilderTest extends SingleHotRodServerTest { | ||
|
||
@Test | ||
private void testGeneratedSchema() { | ||
String generatedSchema = ProtoBuf.builder() | ||
.packageName("org.infinispan") | ||
.message("author") // protobuf message is usually lowercase | ||
.indexed() | ||
.required("name", 1, "string") | ||
.basic() | ||
.sortable(true) | ||
.projectable(true) | ||
.optional("age", 2, "int32") | ||
.keyword() | ||
.sortable(true) | ||
.aggregable(true) | ||
.message("book") | ||
.indexed() | ||
.required("title", 1, "string") | ||
.basic() | ||
.projectable(true) | ||
.optional("yearOfPublication", 2, "int32") | ||
.keyword() | ||
.normalizer("lowercase") | ||
.optional("description", 3, "string") | ||
.text() | ||
.analyzer("english") | ||
.searchAnalyzer("whitespace") | ||
.required("author", 4, "author") | ||
.embedded() | ||
.build(); | ||
|
||
Cache<String, String> metadataCache = cacheManager.getCache( | ||
ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME); | ||
|
||
metadataCache.put("ciao.proto", generatedSchema); | ||
String filesWithErrors = metadataCache.get(ProtobufMetadataManagerConstants.ERRORS_KEY_SUFFIX); | ||
assertThat(filesWithErrors).isNull(); | ||
} | ||
|
||
} |