congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
TopicBuilder.build
Code IndexAdd Tabnine to your IDE (free)

How to use
build
method
in
pl.allegro.tech.hermes.test.helper.builder.TopicBuilder

Best Java code snippets using pl.allegro.tech.hermes.test.helper.builder.TopicBuilder.build (Showing top 15 results out of 315)

origin: allegro/hermes

public TopicWithSchema createTopic(String group, String topic) {
  Topic created = topic(group, topic)
      .withRetentionTime(1000)
      .withDescription("Test topic")
      .build();
  return createTopic(created);
}
origin: pl.allegro.tech.hermes/hermes-test-helper

public TopicWithSchema createTopic(String group, String topic) {
  Topic created = topic(group, topic)
      .withRetentionTime(1000)
      .withDescription("Test topic")
      .build();
  return createTopic(created);
}
origin: allegro/hermes

private Topic createTopic(String group, String name, boolean schemaVersionAwarePayload) {
  return schemaVersionAwarePayload ? topic(group, name).withSchemaVersionAwareSerialization().build() : topic(group, name).build();
}
origin: allegro/hermes

public boolean topicExists(String topicName, String kafkaClusterName) {
  Topic topic = topic(topicName).build();
  return kafkaNamesMapper.toKafkaTopics(topic)
      .allMatch(kafkaTopic -> zkClients.get(kafkaClusterName).topicExists(kafkaTopic.name().asString()) &&
          !isMarkedForDeletion(kafkaClusterName, kafkaTopic));
}
origin: allegro/hermes

@Test
public void shouldThrowExceptionWhenMessageCouldNotBeUnwrappedByAnySchema() {
  // given
  Topic topic = topic("group", "topic").build();
  byte[] doesNotMatchAnySchema = "{}".getBytes();
  // when
  catchException(messageContentWrapper).unwrapAvro(doesNotMatchAnySchema, topic);
  // then
  assertThat(caughtException() instanceof SchemaMissingException).isTrue();
  assertThat(metrics.errorsForAnySchemaVersion().getCount()).isEqualTo(1);
  assertThat(metrics.errorsForAnyOnlineSchemaVersion().getCount()).isEqualTo(1);
}
origin: pl.allegro.tech.hermes/hermes-test-helper

public boolean topicExists(String topicName, String kafkaClusterName) {
  Topic topic = topic(topicName).build();
  return kafkaNamesMapper.toKafkaTopics(topic)
      .allMatch(kafkaTopic -> zkClients.get(kafkaClusterName).topicExists(kafkaTopic.name().asString()) &&
          !isMarkedForDeletion(kafkaClusterName, kafkaTopic));
}
origin: allegro/hermes

@Test
public void shouldUseEveryoneConfirmProducerForTopicWithAckAll() {
  //given
  Topic topic = topic("group.all").withAck(Topic.Ack.ALL).build();
  CachedTopic cachedTopic = new CachedTopic(topic, hermesMetrics, kafkaNamesMapper.toKafkaTopics(topic));
  //when
  producer.send(MESSAGE, cachedTopic, new DoNothing());
  //then
  List<ProducerRecord<byte[], byte[]>> records = everyoneConfirmProducer.history();
  assertThat(records.size()).isEqualTo(1);
  assertThat(records.get(0).topic()).isEqualTo("ns_group.all");
}
origin: allegro/hermes

  @Test
  public void shouldNotResetPrimitiveFields() {
    // given
    Topic topic = topic("group.topic").withTrackingEnabled(true).build();
    PatchData patch = patchData().set("schemaVersionAwareSerializationEnabled", true).build();

    // when
    Topic patched = Patch.apply(topic, patch);

    // then
    assertThat(patched.isTrackingEnabled()).isTrue();
    assertThat(patched.isSchemaVersionAwareSerializationEnabled()).isTrue();
  }
}
origin: allegro/hermes

private void createTopic(String topicName, KafkaZkClient kafkaZkClient) {
  Topic topic = topic(topicName).build();
  kafkaNamesMapper.toKafkaTopics(topic).forEach(kafkaTopic -> {
    AdminZkClient adminZkClient = new AdminZkClient(kafkaZkClient);
    adminZkClient.createTopic(kafkaTopic.name().asString(), DEFAULT_PARTITIONS, DEFAULT_REPLICATION_FACTOR, new Properties(), RackAwareMode.Enforced$.MODULE$);
    waitAtMost(adjust(Duration.ONE_MINUTE)).until(() -> {
          kafkaZkClient.topicExists(kafkaTopic.name().asString());
        }
    );
  });
}
origin: pl.allegro.tech.hermes/hermes-test-helper

private void createTopic(String topicName, KafkaZkClient kafkaZkClient) {
  Topic topic = topic(topicName).build();
  kafkaNamesMapper.toKafkaTopics(topic).forEach(kafkaTopic -> {
    AdminZkClient adminZkClient = new AdminZkClient(kafkaZkClient);
    adminZkClient.createTopic(kafkaTopic.name().asString(), DEFAULT_PARTITIONS, DEFAULT_REPLICATION_FACTOR, new Properties(), RackAwareMode.Enforced$.MODULE$);
    waitAtMost(adjust(Duration.ONE_MINUTE)).until(() -> {
          kafkaZkClient.topicExists(kafkaTopic.name().asString());
        }
    );
  });
}
origin: allegro/hermes

@Test
public void shouldCreateRepositoryThenCloseAndRestore() {
  //given
  Message message = generateMessage();
  String qualifiedName = "groupName.topic";
  Topic topic = topic(qualifiedName).build();
  String baseDir = Files.createTempDir().getAbsolutePath();
  File file = new File(baseDir, "messages.dat");
  messageRepository = new ChronicleMapMessageRepository(file, ENTRIES, AVERAGE_MESSAGE_SIZE);
  //when
  messageRepository.save(message, topic);
  //then
  messageRepository.close();
  //when
  messageRepository = new ChronicleMapMessageRepository(file, ENTRIES, AVERAGE_MESSAGE_SIZE);
  //then
  assertThat(messageRepository.findAll()).contains(new BackupMessage(message.getId(), message.getData(), message.getTimestamp(), qualifiedName));
}
origin: allegro/hermes

@Test
public void shouldSaveFindAndDeleteMessage() {
  //given
  String qualifiedName = "groupName.topic";
  Message message = generateMessage();
  String id = message.getId();
  byte[] messageContent = message.getData();
  long timestamp = message.getTimestamp();
  Topic topic = topic(qualifiedName).build();
  //when
  messageRepository.save(message, topic);
  //then
  assertThat(messageRepository.findAll()).contains(new BackupMessage(id, messageContent, timestamp, qualifiedName));
  //when
  messageRepository.delete(id);
  //then
  assertThat(messageRepository.findAll()).isEmpty();
}
origin: allegro/hermes

@Test
public void shouldSaveMultipleTimesFindAndDeleteMessage() {
  //given
  String messageContent = "hello world";
  Message message1 = generateMessage(messageContent);
  Message message2 = generateMessage(messageContent);
  String id1 = message1.getId();
  String id2 = message2.getId();
  String qualifiedName = "groupName.topic";
  Topic topic = topic(qualifiedName).build();
  //when
  messageRepository.save(message1, topic);
  messageRepository.save(message2, topic);
  messageRepository.save(message1, topic);
  messageRepository.save(message2, topic);
  //then
  assertThat(messageRepository.findAll()).contains(new BackupMessage(id1, messageContent.getBytes(), message1.getTimestamp(), qualifiedName));
  //when
  messageRepository.delete(id1);
  //then
  assertThat(messageRepository.findAll()).hasSize(1);
  assertThat(messageRepository.findAll()).contains(new BackupMessage(id2, messageContent.getBytes(), message2.getTimestamp(), qualifiedName));
}
origin: allegro/hermes

@Test
public void shouldConvertToJsonWithoutMetadata() throws IOException {
  // given
  Topic topic = topic("group.topic").build();
  AvroUser avroUser = new AvroUser("Bob", 18, "blue");
  Message source = message()
      .withData(avroUser.asBytes())
      .withSchema(new CompiledSchema<>(avroUser.getSchema(), SchemaVersion.valueOf(0)))
      .withExternalMetadata(of())
      .build();
  AvroToJsonMessageConverter converter = new AvroToJsonMessageConverter();
  // when
  Message target = converter.convert(source, topic);
  // then
  assertThatJson(new String(target.getData())).isEqualTo("{\"name\": \"Bob\", \"age\": 18, \"favoriteColor\": \"blue\"}");
}
origin: allegro/hermes

private SubscriptionName createSubscription(SubscriptionName subscriptionName) {
  Subscription subscription = subscription(subscriptionName).build();
  Group group = Group.from(subscription.getTopicName().getGroupName());
  if (!groupRepository.groupExists(group.getGroupName())) {
    groupRepository.createGroup(group);
  }
  if (!topicRepository.topicExists(subscription.getTopicName())) {
    topicRepository.createTopic(topic(subscription.getTopicName()).build());
  }
  subscriptionRepository.createSubscription(subscription);
  await().atMost(adjust(ONE_SECOND)).until(
      () -> {
        subscriptionRepository.subscriptionExists(subscription.getTopicName(), subscription.getName());
        subscriptionsCaches.forEach(subscriptionsCache ->
            subscriptionsCache.listActiveSubscriptionNames().contains(subscriptionName));
      }
  );
  return subscription.getQualifiedName();
}
pl.allegro.tech.hermes.test.helper.builderTopicBuilderbuild

Popular methods of TopicBuilder

  • topic
  • <init>
  • withDescription
  • withRetentionTime
  • withAck
  • withSchemaVersionAwareSerialization
  • withTrackingEnabled

Popular in Java

  • Finding current android device location
  • compareTo (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • startActivity (Activity)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now