Commit b63967b5 authored by Alok Joshi's avatar Alok Joshi
Browse files

unit tests, add license

parent 8ba3be25
Pipeline #69868 failed with stages
in 27 minutes and 7 seconds
// Copyright © Microsoft Corporation
//
// 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
//
// 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.
package org.opengroup.osdu.notification.provider.azure.di;
import org.opengroup.osdu.core.common.http.IHttpClient;
......@@ -7,7 +21,6 @@ import org.opengroup.osdu.core.common.notification.ISubscriptionService;
import org.opengroup.osdu.core.common.notification.SubscriptionAPIConfig;
import org.opengroup.osdu.core.common.notification.SubscriptionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
......
package org.opengroup.osdu.notification.di;
import org.junit.Assert;
import org.junit.Test;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.notification.ISubscriptionService;
import org.opengroup.osdu.core.common.notification.SubscriptionAPIConfig;
import org.opengroup.osdu.notification.provider.azure.di.SubscriptionFactoryAzure;
public class SubscriptionFactoryAzureTest {
@Test
public void constructor_should_work_when_config_is_not_null() {
SubscriptionAPIConfig subscriptionAPIConfig = SubscriptionAPIConfig.builder().build();
subscriptionAPIConfig.setApiKey("apiKey");
subscriptionAPIConfig.setRootUrl("rootUrl");
SubscriptionFactoryAzure subscriptionFactoryAzure = new SubscriptionFactoryAzure(subscriptionAPIConfig, null);
Assert.assertNotNull(subscriptionFactoryAzure);
}
@Test(expected = NullPointerException.class)
public void constructor_should_throw_npe_if_config_is_null() {
SubscriptionFactoryAzure subscriptionFactoryAzure = new SubscriptionFactoryAzure(null, null);
}
@Test
public void create_subscriptionService_instance_dpsHeaders_is_not_null() {
DpsHeaders dpsHeaders = new DpsHeaders();
SubscriptionAPIConfig subscriptionAPIConfig = SubscriptionAPIConfig.builder().build();
subscriptionAPIConfig.setApiKey("apiKey");
subscriptionAPIConfig.setRootUrl("rootUrl");
SubscriptionFactoryAzure subscriptionFactoryAzure = new SubscriptionFactoryAzure(subscriptionAPIConfig, null);
ISubscriptionService subscriptionService = subscriptionFactoryAzure.create(dpsHeaders);
Assert.assertNotNull(subscriptionService);
}
@Test(expected = NullPointerException.class)
public void create_subscriptionService_should_throw_npe_if_headers_is_null() {
SubscriptionAPIConfig subscriptionAPIConfig = SubscriptionAPIConfig.builder().build();
subscriptionAPIConfig.setApiKey("apiKey");
subscriptionAPIConfig.setRootUrl("rootUrl");
SubscriptionFactoryAzure subscriptionFactoryAzure = new SubscriptionFactoryAzure(subscriptionAPIConfig, null);
ISubscriptionService subscriptionService = subscriptionFactoryAzure.create(null);
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment