Skip to content

Commit

Permalink
Remove @parallel because otherwise misformated annotation values don'…
Browse files Browse the repository at this point in the history
…t break startup
  • Loading branch information
tobiasschaefer committed Mar 28, 2022
1 parent 46be486 commit 876728e
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package info.novatec.micronaut.zeebe.client.example;

import io.micronaut.context.ApplicationContext;
import io.micronaut.runtime.server.EmbeddedServer;
import org.junit.jupiter.api.Test;

import java.time.format.DateTimeParseException;
import java.util.HashMap;
import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* @author Tobias Schäfer
*/
class AnnotationPropertiesTest {

@Test
void testValidAnnotation() {
Map<String, Object> properties = new HashMap<>();
properties.put("handlerWithInvalidAnnotationPropertiesEnabled", false);
try (EmbeddedServer embeddedServer = ApplicationContext.run(EmbeddedServer.class, properties)) {
assertThat(embeddedServer.isRunning()).isTrue();
assertThat(embeddedServer.getApplicationContext().containsBean(HandlerWithAllAnnotationProperties.class)).isTrue();
}
}

@Test
void testInvalidAnnotation() {
Map<String, Object> properties = new HashMap<>();
properties.put("handlerWithInvalidAnnotationPropertiesEnabled", true);
assertThrows(DateTimeParseException.class, () -> ApplicationContext.run(EmbeddedServer.class, properties));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package info.novatec.micronaut.zeebe.client.example;

import info.novatec.micronaut.zeebe.client.feature.ZeebeWorker;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import io.camunda.zeebe.client.api.worker.JobClient;
import jakarta.inject.Singleton;

/**
* This handler contains all possible annotation properties. It will never be called but the values will be parsed on startup.
*
* @author Tobias Schäfer
*/
@Singleton
public class HandlerWithAllAnnotationProperties {

@ZeebeWorker(type = "some-random-type", timeout = "PT1S", requestTimeout = "PT2S", pollInterval = "PT3S", maxJobsActive = 99)
public void doSomething(JobClient client, ActivatedJob job) {
throw new UnsupportedOperationException("");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2022 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package info.novatec.micronaut.zeebe.client.example;

import info.novatec.micronaut.zeebe.client.feature.ZeebeWorker;
import io.camunda.zeebe.client.api.response.ActivatedJob;
import io.camunda.zeebe.client.api.worker.JobClient;
import io.micronaut.context.annotation.Requires;
import jakarta.inject.Singleton;

/**
* This handler contains an invalid annotation properties which will make the startup fail.
*
* @author Tobias Schäfer
*/
@Singleton
@Requires(property = "handlerWithInvalidAnnotationPropertiesEnabled", value="true")
public class HandlerWithInvalidAnnotationProperties {

@ZeebeWorker(type = "some-random-type-invalid", timeout = "TwentySeconds")
public void doSomething(JobClient client, ActivatedJob job) {
throw new UnsupportedOperationException("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package info.novatec.micronaut.zeebe.client.feature;

import io.micronaut.context.annotation.Executable;
import io.micronaut.context.annotation.Parallel;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
Expand All @@ -32,7 +31,6 @@
@Target(value = {ElementType.TYPE, ElementType.METHOD})
@Documented
@Executable(processOnStartup = true)
@Parallel
public @interface ZeebeWorker {

/**
Expand Down

0 comments on commit 876728e

Please sign in to comment.