Skip to content

Commit

Permalink
ISPN-14724 Test generated proto schema with Infinispan API
Browse files Browse the repository at this point in the history
  • Loading branch information
fax4ever committed Apr 1, 2023
1 parent b60cf62 commit ade0836
Showing 1 changed file with 54 additions and 0 deletions.
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();
}

}

0 comments on commit ade0836

Please sign in to comment.