|
| 1 | +/* |
| 2 | + * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. |
| 3 | + * |
| 4 | + * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 5 | + * |
| 6 | + * Modifications copyright (C) 2017 Uber Technologies, Inc. |
| 7 | + * |
| 8 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | + * you may not use this material except in compliance with the License. |
| 10 | + * You may obtain a copy of the License at |
| 11 | + * |
| 12 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | + * |
| 14 | + * Unless required by applicable law or agreed to in writing, software |
| 15 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | + * See the License for the specific language governing permissions and |
| 18 | + * limitations under the License. |
| 19 | + */ |
| 20 | + |
| 21 | +package io.temporal.client; |
| 22 | + |
| 23 | +import io.temporal.api.cloud.cloudservice.v1.GetNamespaceRequest; |
| 24 | +import io.temporal.api.cloud.cloudservice.v1.GetNamespaceResponse; |
| 25 | +import io.temporal.serviceclient.CloudServiceStubs; |
| 26 | +import io.temporal.serviceclient.CloudServiceStubsOptions; |
| 27 | +import org.junit.Assert; |
| 28 | +import org.junit.Assume; |
| 29 | +import org.junit.Before; |
| 30 | +import org.junit.Test; |
| 31 | + |
| 32 | +public class CloudOperationsClientTest { |
| 33 | + private String namespace; |
| 34 | + private String apiKey; |
| 35 | + private String apiVersion; |
| 36 | + |
| 37 | + @Before |
| 38 | + public void checkCloudEnvVars() { |
| 39 | + namespace = System.getenv("TEMPORAL_CLIENT_CLOUD_NAMESPACE"); |
| 40 | + apiKey = System.getenv("TEMPORAL_CLIENT_CLOUD_API_KEY"); |
| 41 | + apiVersion = System.getenv("TEMPORAL_CLIENT_CLOUD_API_VERSION"); |
| 42 | + Assume.assumeTrue( |
| 43 | + "Cloud environment variables not present", namespace != null && apiKey != null); |
| 44 | + } |
| 45 | + |
| 46 | + @Test |
| 47 | + public void simpleCall() { |
| 48 | + CloudOperationsClient client = |
| 49 | + CloudOperationsClient.newInstance( |
| 50 | + CloudServiceStubs.newServiceStubs( |
| 51 | + CloudServiceStubsOptions.newBuilder() |
| 52 | + .addApiKey(() -> apiKey) |
| 53 | + .setVersion(apiVersion) |
| 54 | + .build())); |
| 55 | + // Do simple get namespace call |
| 56 | + GetNamespaceResponse resp = |
| 57 | + client |
| 58 | + .getCloudServiceStubs() |
| 59 | + .blockingStub() |
| 60 | + .getNamespace(GetNamespaceRequest.newBuilder().setNamespace(namespace).build()); |
| 61 | + Assert.assertEquals(namespace, resp.getNamespace().getNamespace()); |
| 62 | + } |
| 63 | +} |
0 commit comments