Skip to content

Instantly share code, notes, and snippets.

View ctoestreich's full-sized avatar

Christian Oestreich ctoestreich

View GitHub Profile
@ctoestreich
ctoestreich / jfrog-cli-commands.md
Last active July 21, 2024 17:54
jf cli commands
access-token-create, atc         Creates an Artifactory access token. By default an user-scoped token will be created, unless the --groups and/or --grant-admin options are specified.
build-add-dependencies, bad      Adds dependencies from the local file-system to the build info.
build-add-git, bag               Collect VCS details from git and add them to a build.
build-append, ba                 Append published build to the build info.
build-clean, bc                  This command is used to clean (remove) build info collected locally.
build-collect-env, bce           Collect environment variables. Environment variables can be excluded using the build-publish command.
build-discard, bdi               Discard builds by setting retention parameters.
build-docker-create, bdc         Add a published docker image to the build-info.
build-promote, bpr               This command is used to promote build in Artifactory.
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>kafka</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>spock</artifactId>
<scope>test</scope>
</dependency>
class TestEventConsumerSpec extends AbstractEmbeddedKafkaSpec {
def "Test message gets routed"() {
given:
TestConsumer consumer = embeddedServer.getApplicationContext().getBean(TestConsumer)
TestKafkaClient client = embeddedServer.getApplicationContext().getBean(TestKafkaClient)
when:
SomeAvroData event = ...//create test data here
@ctoestreich
ctoestreich / KafkaStreamsHealthDisabledSpec.groovy
Created May 23, 2020 19:17
Example usage of AbstractTestContainersSpec
class KafkaStreamsHealthDisabledSpec extends AbstractTestContainersSpec {
def "health check disabled"() {
when:
def bean = context.findBean(KafkaStreamsHealth)
then:
!bean.isPresent()
}
@ctoestreich
ctoestreich / AbstractTestContainersSpec.groovy
Created May 23, 2020 19:14
Spock Testcontainers Mironaut Kafka Spec
import groovy.util.logging.Slf4j
import io.micronaut.context.ApplicationContext
import io.micronaut.core.util.CollectionUtils
import io.micronaut.runtime.server.EmbeddedServer
import org.apache.kafka.clients.admin.AdminClient
import org.apache.kafka.clients.admin.NewTopic
import org.testcontainers.containers.KafkaContainer
import spock.lang.AutoCleanup
import spock.lang.Shared
import spock.lang.Specification
@ctoestreich
ctoestreich / Value.java
Created March 16, 2020 13:48
Value Annotation
/**
* Generates a lot of code which fits with a class that is a representation of an immutable entity.
* <p>
* Equivalent to {@code @Getter @FieldDefaults(makeFinal=true, level=AccessLevel.PRIVATE) @AllArgsConstructor @ToString @EqualsAndHashCode}.
* <p>
* Complete documentation is found at <a href="https://projectlombok.org/features/Value">the project lombok features page for &#64;Value</a>.
*
* @see lombok.Getter
* @see lombok.experimental.FieldDefaults
* @see lombok.AllArgsConstructor
@ctoestreich
ctoestreich / lombok.config
Created March 15, 2020 01:28
Lombok Config
# https://projectlombok.org/features/configuration
config.stopBubbling = true
lombok.addLombokGeneratedAnnotation = true
lombok.anyConstructor.addConstructorProperties = true
lombok.copyableAnnotations += javax.inject.Named
lombok.copyableAnnotations += io.micronaut.http.client.annotation.Client
lombok.copyableAnnotations += io.micronaut.context.annotation.Parameter
lombok.copyableAnnotations += io.micronaut.context.annotation.Value
lombok.copyableAnnotations += io.micronaut.configuration.hibernate.jpa.scope.CurrentSession
@ctoestreich
ctoestreich / HeadlineClient.java
Last active March 15, 2020 01:20
HeadlineClient
package com.foo.http.client;
import io.micronaut.http.MediaType;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.client.annotation.Client;
import io.reactivex.Flowable;
import reactor.core.publisher.Flux;
@Client("/streaming")
public interface HeadlineClient {
@ctoestreich
ctoestreich / FooEventKafkaClient.java
Created March 15, 2020 01:16
FooEventKafkaClient
package com.foo.event.client;
import io.micronaut.configuration.kafka.annotation.KafkaClient;
import io.micronaut.configuration.kafka.annotation.KafkaKey;
import io.micronaut.configuration.kafka.annotation.Topic;
@KafkaClient(id = "foo-kafka-client")
public interface FooEventKafkaClient {
void publishEvent(@Topic String topic, @KafkaKey final String key, final Foo foo);
@ctoestreich
ctoestreich / FooEventKafkaClient.java
Created February 20, 2020 16:25
FooEventKafkaClient.java
package com.company.project.event.client;
import com.company.project.event.v1.FooEvent;
import io.micronaut.configuration.kafka.annotation.KafkaClient;
import io.micronaut.configuration.kafka.annotation.KafkaKey;
import io.micronaut.configuration.kafka.annotation.Topic;
import io.micronaut.context.annotation.Requires;
import io.micronaut.retry.annotation.Retryable;
@KafkaClient(id = "foo-events-kafka-client")