1+ /*
2+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+ *
4+ * Copyright (c) 2025 Payara Foundation and/or its affiliates. All rights reserved.
5+ *
6+ * The contents of this file are subject to the terms of either the GNU
7+ * General Public License Version 2 only ("GPL") or the Common Development
8+ * and Distribution License("CDDL") (collectively, the "License"). You
9+ * may not use this file except in compliance with the License. You can
10+ * obtain a copy of the License at
11+ * https://github.com/payara/Payara/blob/master/LICENSE.txt
12+ * See the License for the specific
13+ * language governing permissions and limitations under the License.
14+ *
15+ * When distributing the software, include this License Header Notice in each
16+ * file and include the License file at glassfish/legal/LICENSE.txt.
17+ *
18+ * GPL Classpath Exception:
19+ * The Payara Foundation designates this particular file as subject to the "Classpath"
20+ * exception as provided by the Payara Foundation in the GPL Version 2 section of the License
21+ * file that accompanied this code.
22+ *
23+ * Modifications:
24+ * If applicable, add the following below the License Header, with the fields
25+ * enclosed by brackets [] replaced by your own identifying information:
26+ * "Portions Copyright [year] [name of copyright owner]"
27+ *
28+ * Contributor(s):
29+ * If you wish your version of this file to be governed by only the CDDL or
30+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
31+ * elects to include this software in this distribution under the [CDDL or GPL
32+ * Version 2] license." If you don't indicate a single choice of license, a
33+ * recipient has the option to distribute your version of this file under
34+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
35+ * its licensees as provided above. However, if you add GPL Version 2 code
36+ * and therefore, elected the GPL Version 2 license, then the option applies
37+ * only if the new code is made subject to such option by the copyright
38+ * holder.
39+ */
40+ package fish .payara .cloud .connectors .azuresb .api .inbound ;
41+
42+ import jakarta .resource .spi .InvalidPropertyException ;
43+ import jakarta .resource .spi .ResourceAdapter ;
44+ import org .junit .jupiter .api .Test ;
45+
46+ import static org .junit .jupiter .api .Assertions .*;
47+ import static org .mockito .Mockito .*;
48+
49+ class AzureSBActivationSpecTest {
50+
51+ @ Test
52+ void testSettersAndGetters () {
53+ AzureSBActivationSpec spec = new AzureSBActivationSpec ();
54+ spec .setQueueName ("queue1" );
55+ spec .setSasKey ("sas-key-value" );
56+ spec .setSasKeyName ("sas-key-name" );
57+ spec .setNameSpace ("test-namespace" );
58+ assertEquals ("queue1" , spec .getQueueName ());
59+ assertEquals ("sas-key-value" , spec .getSasKey ());
60+ assertEquals ("sas-key-name" , spec .getSasKeyName ());
61+ assertEquals ("test-namespace" , spec .getNameSpace ());
62+ }
63+
64+ @ Test
65+ void testValidateThrowsIfQueueNameNull () {
66+ AzureSBActivationSpec spec = new AzureSBActivationSpec ();
67+ spec .setSasKey ("sas-key-value" );
68+ spec .setSasKeyName ("sas-key-name" );
69+ spec .setNameSpace ("test-namespace" );
70+ assertThrows (InvalidPropertyException .class , spec ::validate );
71+ }
72+
73+ @ Test
74+ void testValidateThrowsIfSasKeyNull () {
75+ AzureSBActivationSpec spec = new AzureSBActivationSpec ();
76+ spec .setQueueName ("queue1" );
77+ spec .setSasKeyName ("sas-key-name" );
78+ spec .setNameSpace ("test-namespace" );
79+ assertThrows (InvalidPropertyException .class , spec ::validate );
80+ }
81+
82+ @ Test
83+ void testValidateThrowsIfSasKeyNameNull () {
84+ AzureSBActivationSpec spec = new AzureSBActivationSpec ();
85+ spec .setQueueName ("queue1" );
86+ spec .setSasKey ("sas-key-value" );
87+ spec .setNameSpace ("test-namespace" );
88+ assertThrows (InvalidPropertyException .class , spec ::validate );
89+ }
90+
91+ @ Test
92+ void testValidateThrowsIfNamespaceNull () {
93+ AzureSBActivationSpec spec = new AzureSBActivationSpec ();
94+ spec .setQueueName ("queue1" );
95+ spec .setSasKey ("sas-key-value" );
96+ spec .setSasKeyName ("sas-key-name" );
97+ assertThrows (InvalidPropertyException .class , spec ::validate );
98+ }
99+
100+ @ Test
101+ void testValidateSucceedsIfAllSet () {
102+ AzureSBActivationSpec spec = new AzureSBActivationSpec ();
103+ spec .setQueueName ("queue1" );
104+ spec .setSasKey ("sas-key-value" );
105+ spec .setSasKeyName ("sas-key-name" );
106+ spec .setNameSpace ("test-namespace" );
107+ assertDoesNotThrow (spec ::validate );
108+ }
109+
110+ @ Test
111+ void testResourceAdapterSetAndGet () throws Exception {
112+ AzureSBActivationSpec spec = new AzureSBActivationSpec ();
113+ ResourceAdapter adapter = mock (ResourceAdapter .class );
114+ spec .setResourceAdapter (adapter );
115+ assertEquals (adapter , spec .getResourceAdapter ());
116+ }
117+ }
0 commit comments