Skip to content

Commit

Permalink
#671 prevents from creating invalid topic
Browse files Browse the repository at this point in the history
  • Loading branch information
pbetkier committed Dec 19, 2016
1 parent 6c9d654 commit 4583f5d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ allprojects {
targetCompatibility = 1.8

project.ext.versions = [
guava : '19.0',
guava : '20.0',
jackson : '2.5.1',
jersey : '2.23.2',
jetty : '9.3.6.v20151106',
Expand Down Expand Up @@ -115,6 +115,8 @@ subprojects {
configurations {
all*.exclude group: "org.slf4j", module: "slf4j-log4j12"
all*.exclude group: "log4j", module: "log4j"
all*.resolutionStrategy*.force 'org.jboss.logging:jboss-logging:3.2.1.Final'
all*.resolutionStrategy*.force "com.google.guava:guava:${versions.guava}"
}

tasks.withType(JavaCompile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public TopicService(MultiDCAwareService multiDCAwareService,

public void createTopic(Topic topic, String createdBy) {
topicValidator.ensureCreatedTopicIsValid(topic);
topicRepository.createTopic(topic);
preconditions.checkConstraints(topic);
topicRepository.createTopic(topic);

if (!multiDCAwareService.topicExists(topic)) {
createTopicInBrokers(topic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ public void shouldRecreateTopicAfterDeletion() {
Assertions.assertThat(management.topic().get("recreateTopicGroup.topic")).isNotNull();
}

@Test
public void shouldNotCreateInvalidTopic() {
// given
operations.createGroup("invalidTopicGroup");

// when
Response response = management.topic().create(topic("invalidTopicGroup", "topic").withRetentionTime(-1).build());

// then
assertThat(response).hasStatus(Response.Status.BAD_REQUEST).hasErrorCode(ErrorCode.VALIDATION_ERROR);
Assertions.assertThat(management.topic().list("invalidTopicGroup", false)).isEmpty();
}

@Test
public void shouldNotAllowOnCreatingSameTopicTwice() {
// given
Expand Down

0 comments on commit 4583f5d

Please sign in to comment.