Skip to content

Commit

Permalink
Fix test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
aashikam committed Aug 18, 2023
1 parent 9bad782 commit 521edb3
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,21 @@ private void validateAttachPoint(SyntaxNodeAnalysisContext context) {
SemanticModel semanticModel = context.semanticModel();
ServiceDeclarationNode serviceDeclarationNode = (ServiceDeclarationNode) context.node();
Optional<Symbol> symbol = semanticModel.symbol(serviceDeclarationNode);

if (symbol.isPresent()) {
ServiceDeclarationSymbol serviceDeclarationSymbol = (ServiceDeclarationSymbol) symbol.get();
Optional<ServiceAttachPoint> serviceNameAttachPoint = serviceDeclarationSymbol.attachPoint();
List<AnnotationSymbol> annotations = serviceDeclarationSymbol.annotations();

// nats gets the subject name from either the service name or the
// service config, so either one of them should be present.
if (annotations.isEmpty() || !hasServiceConfig(annotations)) {
if (serviceNameAttachPoint.isEmpty()) {
// Case 1: No service name and no annotation
reportError(context, CompilationErrors.NO_ANNOTATION, serviceDeclarationNode);
} else if (serviceNameAttachPoint.get().kind() != ServiceAttachPointKind.STRING_LITERAL) {
// Case 2: Service name is not a string and no annotation
reportError(context, CompilationErrors.INVALID_SERVICE_ATTACH_POINT, serviceDeclarationNode);
}
if (annotations.isEmpty() && (serviceNameAttachPoint.isEmpty() ||
serviceNameAttachPoint.get().kind() != ServiceAttachPointKind.STRING_LITERAL)) {
// Case 1: No service name and no annotation
reportError(context, CompilationErrors.INVALID_SERVICE_ATTACH_POINT, serviceDeclarationNode);
} else if (!hasServiceConfig(annotations) &&
serviceNameAttachPoint.isPresent() &&
serviceNameAttachPoint.get().kind() != ServiceAttachPointKind.STRING_LITERAL) {
// Case 2: Service name is not a string and no annotation
reportError(context, CompilationErrors.INVALID_SERVICE_ATTACH_POINT, serviceDeclarationNode);
}
}
}
Expand Down

0 comments on commit 521edb3

Please sign in to comment.