Skip to content

Commit 4b7c6f2

Browse files
authored
Add test cases for server and versioning (microsoft#5595)
Add test cases to folder be under `server` and `versioning`.
1 parent 4d96eeb commit 4b7c6f2

File tree

60 files changed

+447
-237
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+447
-237
lines changed

packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/parameters/collectionformat/CollectionFormatClientTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,38 @@
66
import java.util.Arrays;
77
import org.junit.jupiter.api.Test;
88

9-
class CollectionFormatClientTest {
9+
public class CollectionFormatClientTest {
1010

1111
private final QueryClient client = new CollectionFormatClientBuilder().buildQueryClient();
1212
private final HeaderClient headerClient = new CollectionFormatClientBuilder().buildHeaderClient();
1313

1414
@Test
15-
void testMulti() {
15+
public void testMulti() {
1616
client.multi(Arrays.asList("blue", "red", "green"));
1717
}
1818

1919
@Test
20-
void testCsv() {
20+
public void testCsv() {
2121
client.csv(Arrays.asList("blue", "red", "green"));
2222
}
2323

2424
@Test
25-
void testSsv() {
25+
public void testSsv() {
2626
client.ssv(Arrays.asList("blue", "red", "green"));
2727
}
2828

2929
@Test
30-
void testTsv() {
30+
public void testTsv() {
3131
client.tsv(Arrays.asList("blue", "red", "green"));
3232
}
3333

3434
@Test
35-
void testPipe() {
35+
public void testPipe() {
3636
client.pipes(Arrays.asList("blue", "red", "green"));
3737
}
3838

3939
@Test
40-
void testCsvHeader() {
40+
public void testCsvHeader() {
4141
headerClient.csv(Arrays.asList("blue", "red", "green"));
4242
}
4343

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package server.path.multiple;
5+
6+
import org.junit.jupiter.api.Test;
7+
8+
public class MultipleClientTest {
9+
10+
private final MultipleClient client = new MultipleClientBuilder().endpoint("http://localhost:3000").buildClient();
11+
12+
@Test
13+
public void noOperationParams() {
14+
client.noOperationParams();
15+
}
16+
17+
@Test
18+
public void withOperationPathParam() {
19+
client.withOperationPathParam("test");
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package server.path.single;
5+
6+
import org.junit.jupiter.api.Test;
7+
8+
public class SingleClientTest {
9+
10+
private final SingleClient client = new SingleClientBuilder().endpoint("http://localhost:3000").buildClient();
11+
12+
@Test
13+
public void myOp() {
14+
client.myOp();
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package server.versions;
5+
6+
import org.junit.jupiter.api.Test;
7+
import server.versions.notversioned.NotVersionedClient;
8+
import server.versions.notversioned.NotVersionedClientBuilder;
9+
10+
public class NotVersionedTests {
11+
12+
private final NotVersionedClient client
13+
= new NotVersionedClientBuilder().endpoint("http://localhost:3000").buildClient();
14+
15+
@Test
16+
public void test() {
17+
client.withoutApiVersion();
18+
19+
client.withPathApiVersion("v1.0");
20+
21+
client.withQueryApiVersion("v1.0");
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package server.versions;
5+
6+
import org.junit.jupiter.api.Test;
7+
import server.versions.versioned.VersionedClient;
8+
import server.versions.versioned.VersionedClientBuilder;
9+
import server.versions.versioned.VersionedServiceVersion;
10+
11+
public class VersionedTests {
12+
13+
private final VersionedClient client = new VersionedClientBuilder().endpoint("http://localhost:3000")
14+
.serviceVersion(VersionedServiceVersion.V2022_12_01_PREVIEW)
15+
.buildClient();
16+
17+
@Test
18+
public void test() {
19+
client.withoutApiVersion();
20+
21+
client.withPathApiVersion();
22+
23+
client.withQueryApiVersion();
24+
25+
VersionedClient oldClient = new VersionedClientBuilder().endpoint("http://localhost:3000")
26+
.serviceVersion(VersionedServiceVersion.V2021_01_01_PREVIEW)
27+
.buildClient();
28+
oldClient.withQueryOldApiVersion();
29+
}
30+
}

packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/BooleanValueClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
import org.junit.jupiter.api.Assertions;
99
import org.junit.jupiter.api.Test;
1010

11-
class BooleanValueClientTest {
11+
public class BooleanValueClientTest {
1212

13-
BooleanValueClient client = new ArrayClientBuilder().buildBooleanValueClient();
13+
private final BooleanValueClient client = new ArrayClientBuilder().buildBooleanValueClient();
1414

1515
@Test
16-
void get() {
16+
public void get() {
1717
List<Boolean> response = client.get();
1818
Assertions.assertEquals(2, response.size());
1919
Assertions.assertEquals(true, response.get(0));
2020
Assertions.assertEquals(false, response.get(1));
2121
}
2222

2323
@Test
24-
void put() {
24+
public void put() {
2525
List<Boolean> body = Arrays.asList(true, false);
2626
client.put(body);
2727
}

packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DatetimeValueClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
import org.junit.jupiter.api.Disabled;
1111
import org.junit.jupiter.api.Test;
1212

13-
class DatetimeValueClientTest {
13+
public class DatetimeValueClientTest {
1414

15-
DatetimeValueClient client = new ArrayClientBuilder().buildDatetimeValueClient();
15+
private final DatetimeValueClient client = new ArrayClientBuilder().buildDatetimeValueClient();
1616

1717
@Test
18-
void get() {
18+
public void get() {
1919
List<OffsetDateTime> response = client.get();
2020
Assertions.assertEquals(1, response.size());
2121
Assertions.assertEquals("2022-08-26T18:38:00Z", response.get(0));
2222
}
2323

2424
@Test
2525
@Disabled("Body provided doesn't match expected body,\"expected\":[\"2022-08-26T18:38:00Z\"],\"actual\":[\"2022-08-26T18:38Z\"]")
26-
void put() {
26+
public void put() {
2727
List<OffsetDateTime> body = Arrays.asList(OffsetDateTime.parse("2022-08-26T18:38:00Z"));
2828
client.put(body);
2929
}

packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/DurationValueClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
import org.junit.jupiter.api.Disabled;
1111
import org.junit.jupiter.api.Test;
1212

13-
class DurationValueClientTest {
13+
public class DurationValueClientTest {
1414

15-
DurationValueClient client = new ArrayClientBuilder().buildDurationValueClient();
15+
private final DurationValueClient client = new ArrayClientBuilder().buildDurationValueClient();
1616

1717
@Test
18-
void get() {
18+
public void get() {
1919
List<Duration> response = client.get();
2020
Assertions.assertEquals(1, response.size());
2121
Assertions.assertEquals("P123DT22H14M12.011S", response.get(0));
2222
}
2323

2424
@Test
2525
@Disabled("Body provided doesn't match expected body,\"expected\":[\"P123DT22H14M12.011S\"],\"actual\":[\"PT2974H14M12.011S\"]")
26-
void put() {
26+
public void put() {
2727
Duration duration = Duration.parse("P123DT22H14M12.011S");
2828
client.put(Arrays.asList(duration));
2929
}

packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Float32ValueClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
import org.junit.jupiter.api.Assertions;
99
import org.junit.jupiter.api.Test;
1010

11-
class Float32ValueClientTest {
11+
public class Float32ValueClientTest {
1212

13-
Float32ValueClient client = new ArrayClientBuilder().buildFloat32ValueClient();
13+
private final Float32ValueClient client = new ArrayClientBuilder().buildFloat32ValueClient();
1414

1515
@Test
16-
void get() {
16+
public void get() {
1717
List<Double> response = client.get();
1818
Assertions.assertEquals(1, response.size());
1919
Assertions.assertEquals(43.125, response.get(0));
2020
}
2121

2222
@Test
23-
void put() {
23+
public void put() {
2424
client.put(Arrays.asList(43.125));
2525
}
2626
}

packages/http-client-java/generator/http-client-generator-clientcore-test/src/test/java/type/array/Int64ValueClientTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
import org.junit.jupiter.api.Assertions;
99
import org.junit.jupiter.api.Test;
1010

11-
class Int64ValueClientTest {
11+
public class Int64ValueClientTest {
1212

13-
Int64ValueClient client = new ArrayClientBuilder().buildInt64ValueClient();
13+
private final Int64ValueClient client = new ArrayClientBuilder().buildInt64ValueClient();
1414

1515
@Test
16-
void get() {
16+
public void get() {
1717
List<Long> response = client.get();
1818
Assertions.assertEquals(2, response.size());
1919
Assertions.assertEquals(9007199254740991L, response.get(0));
2020
Assertions.assertEquals(-9007199254740991L, response.get(1));
2121
}
2222

2323
@Test
24-
void put() {
24+
public void put() {
2525
client.put(Arrays.asList(9007199254740991L, -9007199254740991L));
2626
}
2727
}

0 commit comments

Comments
 (0)