Skip to content

Commit

Permalink
Add test for invalid attach point
Browse files Browse the repository at this point in the history
  • Loading branch information
aashikam committed Aug 21, 2023
1 parent 2c73264 commit e101fee
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,16 @@ public void testInvalidService30() {
assertDiagnostic(diagnostic, CompilationErrors.NO_ANNOTATION);
}

@Test(description = "NATS service with no service config or service name")
public void testInvalidService30() {
Package currentPackage = loadPackage("invalid_service_31");
PackageCompilation compilation = currentPackage.getCompilation();
DiagnosticResult diagnosticResult = compilation.diagnosticResult();
Assert.assertEquals(diagnosticResult.errors().size(), 1);
Diagnostic diagnostic = (Diagnostic) diagnosticResult.errors().toArray()[0];
assertDiagnostic(diagnostic, CompilationErrors.INVALID_SERVICE_ATTACH_POINT);
}

private Package loadPackage(String path) {
Path projectDirPath = RESOURCE_DIRECTORY.resolve(BALLERINA_SOURCES).resolve(path);
BuildProject project = BuildProject.load(getEnvironmentBuilder(), projectDirPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
org = "nats_test"
name = "invalid_service_31"
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
//
// WSO2 LLC. licenses this file to you 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
//
// http://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.

import ballerinax/nats;

listener nats:Listener subscription = new(nats:DEFAULT_URL);

@display {
label: "natsService"
}
service nats:Service on subscription {

remote function onMessage(nats:Message message) returns error? {
}
}

0 comments on commit e101fee

Please sign in to comment.