Skip to content

Commit

Permalink
item(TCOMP-2743):add junit case
Browse files Browse the repository at this point in the history
  • Loading branch information
yyin-talend committed Jun 26, 2024
1 parent 6be2713 commit d4bb386
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.apache.xbean.finder.AnnotationFinder;
import org.apache.xbean.finder.archive.ClassesArchive;
import org.junit.jupiter.api.Test;
import org.talend.sdk.component.api.service.dependency.DynamicDependencies;
import org.talend.sdk.component.api.service.http.HttpClient;
import org.talend.sdk.component.api.service.http.Request;

Expand All @@ -32,14 +33,23 @@ void validateClassDoNotExtendHttpClient() {
}

@Test
void validateClassMethodMissingAnnotation() {
void validateClassMethodMissingRequestAnnotation() {
final HttpValidator validator = new HttpValidator();
AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(WrongClient.class));
final Stream<String> errors =
validator.validate(finder, Arrays.asList(WrongClient.class));
assertEquals(1, errors.count());
}

@Test
void validateClassMethodWithOtherAnnotation() {
final HttpValidator validator = new HttpValidator();
AnnotationFinder finder = new AnnotationFinder(new ClassesArchive(WithOtherAnnotationClient.class));
final Stream<String> errors =
validator.validate(finder, Arrays.asList(WithOtherAnnotationClient.class));
assertEquals(1, errors.count());
}

@Test
void validateClassOK() {
final HttpValidator validator = new HttpValidator();
Expand Down Expand Up @@ -76,4 +86,14 @@ interface WrongClient extends HttpClient {
@Request(method = "POST")
String queryB(String ok);
}

interface WithOtherAnnotationClient extends HttpClient {

// It misses @Request
@DynamicDependencies
String queryA(String ok);

@Request(method = "POST")
String queryB(String ok);
}
}

0 comments on commit d4bb386

Please sign in to comment.