本文整理汇总了Java中com.google.protobuf.StringValue类的典型用法代码示例。如果您正苦于以下问题:Java StringValue类的具体用法?Java StringValue怎么用?Java StringValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringValue类属于com.google.protobuf包,在下文中一共展示了StringValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldMarshalValue
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void shouldMarshalValue() throws IOException {
// Given:
final StringValue val = StringValue.newBuilder().setValue("test").build();
// When:
final byte[] buf;
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
provider.writeTo(val, val.getClass(), null, EMPTY_ANNOTATIONS, MediaType.APPLICATION_JSON_TYPE, null, os);
buf = os.toByteArray();
}
// Then:
assertTrue(provider.isReadable(StringValue.class, null, EMPTY_ANNOTATIONS, MediaType.APPLICATION_JSON_TYPE));
assertTrue(provider.isWriteable(StringValue.class, null, EMPTY_ANNOTATIONS, MediaType.APPLICATION_JSON_TYPE));
try (final ByteArrayInputStream is = new ByteArrayInputStream(buf)) {
@SuppressWarnings("unchecked") final Class<Object> clazz = (Class) val.getClass();
final Object actual = provider.readFrom(clazz, null, EMPTY_ANNOTATIONS, MediaType.APPLICATION_JSON_TYPE, null, is);
assertEquals(val, actual);
}
}
开发者ID:truward,项目名称:protobuf-jaxrs,代码行数:23,代码来源:ProtobufJacksonProviderTest.java
示例2: shouldDeserializeUtf16Message
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void shouldDeserializeUtf16Message() throws IOException {
// Given:
final String json = "{\"value\": \"Test\"}";
final Charset charset = Charset.forName("UTF-16");
final byte[] jsonBytes = json.getBytes(charset);
final MediaType mediaType = new MediaType("application", "json", charset.name());
// When:
final Object actual;
try (final ByteArrayInputStream is = new ByteArrayInputStream(jsonBytes)) {
@SuppressWarnings("unchecked") final Class<Object> clazz = (Class) StringValue.class;
actual = provider.readFrom(clazz, null, EMPTY_ANNOTATIONS, mediaType, null, is);
}
// Then:
final StringValue val = (StringValue) actual;
assertEquals("Test", val.getValue());
}
开发者ID:truward,项目名称:protobuf-jaxrs,代码行数:20,代码来源:ProtobufJacksonProviderTest.java
示例3: shouldParseCompatibleTypes
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void shouldParseCompatibleTypes() throws IOException {
// Given:
final StringValue val = StringValue.newBuilder().setValue("test").build();
// When:
final byte[] buf;
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
provider.writeTo(val, val.getClass(), null, EMPTY_ANNOTATIONS, ProtobufMediaType.MEDIA_TYPE, null, os);
buf = os.toByteArray();
}
// Then:
assertTrue(provider.isReadable(BytesValue.class, null, EMPTY_ANNOTATIONS, ProtobufMediaType.MEDIA_TYPE));
assertTrue(provider.isWriteable(BytesValue.class, null, EMPTY_ANNOTATIONS, ProtobufMediaType.MEDIA_TYPE));
try (final ByteArrayInputStream is = new ByteArrayInputStream(buf)) {
@SuppressWarnings("unchecked") final Class<Object> clazz = (Class) val.getClass();
final Object actual = provider.readFrom(clazz, null, EMPTY_ANNOTATIONS, ProtobufMediaType.MEDIA_TYPE, null, is);
assertEquals(val, actual);
}
}
开发者ID:truward,项目名称:protobuf-jaxrs,代码行数:23,代码来源:ProtobufProviderTest.java
示例4: sort_commands_by_timestamp
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void sort_commands_by_timestamp() {
final Command cmd1 = requestFactory.createCommand(StringValue.getDefaultInstance(),
minutesAgo(1));
final Command cmd2 = requestFactory.createCommand(Int64Value.getDefaultInstance(),
secondsAgo(30));
final Command cmd3 = requestFactory.createCommand(BoolValue.getDefaultInstance(),
secondsAgo(5));
final List<Command> sortedCommands = newArrayList(cmd1, cmd2, cmd3);
final List<Command> commandsToSort = newArrayList(cmd3, cmd1, cmd2);
assertFalse(sortedCommands.equals(commandsToSort));
Commands.sort(commandsToSort);
assertEquals(sortedCommands, commandsToSort);
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:17,代码来源:CommandsShould.java
示例5: create_wereBetween_predicate
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void create_wereBetween_predicate() {
final Command command1 = requestFactory.createCommand(StringValue.getDefaultInstance(),
minutesAgo(5));
final Command command2 = requestFactory.createCommand(Int64Value.getDefaultInstance(),
minutesAgo(2));
final Command command3 = requestFactory.createCommand(BoolValue.getDefaultInstance(),
secondsAgo(30));
final Command command4 = requestFactory.createCommand(BoolValue.getDefaultInstance(),
secondsAgo(20));
final Command command5 = requestFactory.createCommand(BoolValue.getDefaultInstance(),
secondsAgo(5));
final ImmutableList<Command> commands =
ImmutableList.of(command1, command2, command3, command4, command5);
final Iterable<Command> filter = Iterables.filter(
commands,
Commands.wereWithinPeriod(minutesAgo(3), secondsAgo(10))
);
assertEquals(3, FluentIterable.from(filter)
.size());
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:24,代码来源:CommandsShould.java
示例6: create_entity
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void create_entity() {
final long id = 1024L;
final int version = 100500;
final StringValue state = toMessage(getClass().getName());
final Timestamp timestamp = Time.getCurrentTime();
final VersionableEntity entity = givenEntity()
.withId(id)
.withVersion(version)
.withState(state)
.modifiedOn(timestamp)
.build();
assertEquals(TestEntity.class, entity.getClass());
assertEquals(id, entity.getId());
assertEquals(state, entity.getState());
assertEquals(version, entity.getVersion().getNumber());
assertEquals(timestamp, entity.getVersion().getTimestamp());
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:21,代码来源:EntityBuilderShould.java
示例7: expose_playing_events_to_the_package
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void expose_playing_events_to_the_package() {
final TestEventFactory eventFactory = TestEventFactory.newInstance(getClass());
final StringValue strValue = StringValue.newBuilder()
.setValue("eins zwei drei")
.build();
final Int32Value intValue = Int32Value.newBuilder().setValue(123).build();
final Version nextVersion = Versions.increment(projection.getVersion());
final Event e1 = eventFactory.createEvent(strValue, nextVersion);
final Event e2 = eventFactory.createEvent(intValue, Versions.increment(nextVersion));
final boolean projectionChanged = Projection.play(projection, ImmutableList.of(e1, e2));
final String projectionState = projection.getState()
.getValue();
assertTrue(projectionChanged);
assertTrue(projectionState.contains(strValue.getValue()));
assertTrue(projectionState.contains(String.valueOf(intValue.getValue())));
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:21,代码来源:ProjectionShould.java
示例8: log_error_if_dispatch_unknown_event
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void log_error_if_dispatch_unknown_event() {
final StringValue unknownEventMessage = StringValue.getDefaultInstance();
final Event event = GivenEvent.withMessage(unknownEventMessage);
repository().dispatch(EventEnvelope.of(event));
TestProjectionRepository testRepo = (TestProjectionRepository)repository();
assertTrue(testRepo.getLastErrorEnvelope() instanceof EventEnvelope);
assertEquals(Events.getMessage(event), testRepo.getLastErrorEnvelope()
.getMessage());
assertEquals(event, testRepo.getLastErrorEnvelope().getOuterObject());
// It must be "illegal argument type" since projections of this repository
// do not handle such events.
assertTrue(testRepo.getLastException() instanceof IllegalArgumentException);
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:20,代码来源:ProjectionRepositoryShould.java
示例9: create_and_initialize_entity_instance
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void create_and_initialize_entity_instance() {
final Long id = 100L;
final Timestamp before = TimeTests.Past.secondsAgo(1);
// Create and init the entity.
final EntityClass<NanoEntity> entityClass = new EntityClass<>(NanoEntity.class);
final AbstractVersionableEntity<Long, StringValue> entity = entityClass.createEntity(id);
final Timestamp after = Time.getCurrentTime();
// The interval with a much earlier start to allow non-zero interval on faster computers.
final Interval whileWeCreate = Intervals.between(before, after);
assertEquals(id, entity.getId());
assertEquals(0, entity.getVersion()
.getNumber());
assertTrue(Intervals.contains(whileWeCreate, entity.whenModified()));
assertEquals(StringValue.getDefaultInstance(), entity.getState());
assertFalse(entity.isArchived());
assertFalse(entity.isDeleted());
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:23,代码来源:EntityClassShould.java
示例10: expose_external_dispatcher_that_delegates_onError
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void expose_external_dispatcher_that_delegates_onError() {
final ExternalMessageDispatcher<String> extMessageDispatcher =
delegatingDispatcher.getExternalDispatcher();
final TestEventFactory factory = TestEventFactory.newInstance(getClass());
final StringValue eventMsg = newUuidValue();
final Event event = factory.createEvent(eventMsg);
final ExternalMessage externalMessage =
ExternalMessages.of(event, BoundedContext.newName(getClass().getName()));
final ExternalMessageEnvelope externalMessageEnvelope =
ExternalMessageEnvelope.of(externalMessage, eventMsg);
final RuntimeException exception =
new RuntimeException("test external dispatcher delegating onError");
extMessageDispatcher.onError(externalMessageEnvelope,exception);
assertTrue(delegate.onErrorCalled());
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:21,代码来源:DelegatingEventDispatcherShould.java
示例11: create_iterating_router
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void create_iterating_router() {
final StringValue commandMessage = toMessage("create_iterating_router");
final CommandContext commandContext = requestFactory.createCommandContext();
processManager.injectCommandBus(mock(CommandBus.class));
final IteratingCommandRouter router
= processManager.newIteratingRouterFor(commandMessage,
commandContext);
assertNotNull(router);
assertEquals(commandMessage, getMessage(router.getSource()));
assertEquals(commandContext, router.getSource()
.getContext());
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:17,代码来源:ProcessManagerShould.java
示例12: return_CommandRouted_from_routeFirst
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void return_CommandRouted_from_routeFirst() throws Exception {
final CommandRouted commandRouted = router().routeFirst();
assertSource(commandRouted);
// Test that only only one command was produced by `routeFirst()`.
assertEquals(1, commandRouted.getProducedCount());
// Test that there's only one produced command and it has correct message.
final Command produced = commandRouted.getProduced(0);
final StringValue commandMessage = Commands.getMessage(produced);
assertEquals(messages().get(0), commandMessage);
assertActorAndTenant(produced);
// Test that the event contains messages to follow.
assertEquals(messages().size() - 1, commandRouted.getMessageToFollowCount());
final List<Any> messageToFollow = commandRouted.getMessageToFollowList();
assertArrayEquals(messages().subList(1, messages().size()).toArray(),
unpackAll(messageToFollow).toArray());
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:24,代码来源:IteratingCommandRouterShould.java
示例13: validEvent
import com.google.protobuf.StringValue; //导入依赖的package包/类
static Event validEvent() {
final Command cmd = validCommand();
final PrjProjectCreated eventMessage = PrjProjectCreated.newBuilder()
.setProjectId(ProjectId.newBuilder()
.setId("12345AD0"))
.build();
final StringValue producerId = toMessage(Given.class.getSimpleName());
final EventFactory eventFactory = EventFactory.on(CommandEnvelope.of(cmd),
Identifier.pack(producerId));
final Event event = eventFactory.createEvent(eventMessage, Tests.<Version>nullRef());
final Event result = event.toBuilder()
.setContext(event.getContext()
.toBuilder()
.setEnrichment(Enrichment.newBuilder()
.setDoNotEnrich(true))
.build())
.build();
return result;
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:20,代码来源:Given.java
示例14: apply_default_route
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void apply_default_route() {
final TestActorRequestFactory factory = TestActorRequestFactory.newInstance(getClass());
// Replace the default route since we have custom command message.
commandRouting.replaceDefault(customDefault)
// Have custom route too.
.route(StringValue.class, customRoute);
final CommandEnvelope command =
CommandEnvelope.of(factory.createCommand(Time.getCurrentTime()));
final long id = commandRouting.apply(command.getMessage(), command.getCommandContext());
assertEquals(DEFAULT_ANSWER, id);
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:17,代码来源:CommandRoutingShould.java
示例15: dispatch_event
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Test
public void dispatch_event() {
final TestEventFactory factory = TestEventFactory.newInstance(getClass());
final float messageValue = 2017.0729f;
final FloatValue message = FloatValue.newBuilder()
.setValue(messageValue)
.build();
final EventEnvelope eventEnvelope = EventEnvelope.of(factory.createEvent(message));
final List<? extends Message> eventMessages = dispatchEvent(aggregate, eventEnvelope);
assertTrue(aggregate.getState()
.getValue()
.contains(String.valueOf(messageValue)));
assertEquals(1, eventMessages.size());
assertTrue(eventMessages.get(0) instanceof StringValue);
}
开发者ID:SpineEventEngine,项目名称:core-java,代码行数:18,代码来源:AggregateMessageDispatcherShould.java
示例16: getUser
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Override
public Mono<UserProto> getUser(Mono<StringValue> request) {
return request
.map(StringValue::getValue)
.doOnSuccess(login -> log.debug("gRPC request to get User : {}", login))
.map(login -> userService.getUserWithAuthoritiesByLogin(login).orElseThrow(Status.NOT_FOUND::asRuntimeException))
.map(userProtoMapper::userToUserProto);
}
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:9,代码来源:_UserGrpcService.java
示例17: deleteUser
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Override
public Mono<Empty> deleteUser(Mono<StringValue> request) {
return request
.map(StringValue::getValue)
.doOnSuccess(login -> log.debug("gRPC request to delete User: {}", login))
.doOnSuccess(userService::deleteUser)
.map(l -> Empty.newBuilder().build());
}
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:9,代码来源:_UserGrpcService.java
示例18: getAllAuthorities
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Override
public Flux<StringValue> getAllAuthorities(Mono<Empty> request) {
return request
.doOnSuccess(e -> log.debug("gRPC request to gat all authorities"))
.filter(e -> SecurityUtils.isCurrentUserInRole(AuthoritiesConstants.ADMIN))
.switchIfEmpty(Mono.error(Status.PERMISSION_DENIED.asRuntimeException()))
.flatMapIterable(e -> userService.getAuthorities())
.map(authority -> StringValue.newBuilder().setValue(authority).build());
}
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:10,代码来源:_UserGrpcService.java
示例19: searchUsers
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Override
public Flux<UserProto> searchUsers(Mono<UserSearchPageRequest> request) {
return request
.map(UserSearchPageRequest::getQuery)
.map(StringValue::getValue)
.doOnSuccess(query -> log.debug("gRPC request to search Users for query {}", query))
.map(QueryBuilders::queryStringQuery)
.flatMapMany(query -> request
.map(UserSearchPageRequest::getPageRequest)
.map(ProtobufMappers::pageRequestProtoToPageRequest)
.flatMapIterable(pageRequest -> userSearchRepository.search(query, pageRequest))
)
.map(userProtoMapper::userToUserProto);
}
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:15,代码来源:_UserGrpcService.java
示例20: isAuthenticated
import com.google.protobuf.StringValue; //导入依赖的package包/类
@Override
public Mono<StringValue> isAuthenticated(Mono<Empty> request) {
return request.map(e -> {
log.debug("gRPC request to check if the current user is authenticated");
Authentication principal = SecurityContextHolder.getContext().getAuthentication();
StringValue.Builder builder = StringValue.newBuilder();
if (principal != null) {
builder.setValue(principal.getName());
}
return builder.build();
});
}
开发者ID:cbornet,项目名称:generator-jhipster-grpc,代码行数:13,代码来源:_AccountService.java
注:本文中的com.google.protobuf.StringValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论