Skip to content

Commit

Permalink
fix resttemplate CustomTest for JUnit 5
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-mfg committed Dec 8, 2024
1 parent b14bc7a commit 83e638b
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,20 @@

package org.openapitools.client;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.openapitools.client.api.BodyApi;
import org.openapitools.client.api.QueryApi;
import org.openapitools.client.model.Category;
import org.openapitools.client.model.Pet;

import java.util.Arrays;

import static org.junit.Assert.assertNotNull;


/**
* API tests
*/
public class CustomTest {
class CustomTest {

private final QueryApi api = new QueryApi();
private final BodyApi bodyApi = new BodyApi();
Expand All @@ -40,22 +38,22 @@ public class CustomTest {
*
*/
@Test
public void testEchoBodyPet() {
void testEchoBodyPet() {
Pet pet = new Pet().id(12345L).name("Hello World").
photoUrls(Arrays.asList(new String[]{"http://a.com", "http://b.com"})).category(new Category().id(987L).name("new category"));

Pet p = bodyApi.testEchoBodyPet(pet);
assertNotNull(p);
Assert.assertEquals("Hello World", p.getName());
Assert.assertEquals(Long.valueOf(12345L), p.getId());
Assertions.assertNotNull(p);
Assertions.assertEquals("Hello World", p.getName());
Assertions.assertEquals(Long.valueOf(12345L), p.getId());

// response is empty body
Pet p2 = bodyApi.testEchoBodyPet(null);
Assert.assertNull(p2);
Assertions.assertNull(p2);
}

@Test
public void testQueryParamsExploded_whenQueryParamIsNull() {
assertNotNull(api.testQueryStyleFormExplodeTrueObject(null));
void testQueryParamsExploded_whenQueryParamIsNull() {
Assertions.assertNotNull(api.testQueryStyleFormExplodeTrueObject(null));
}
}

0 comments on commit 83e638b

Please sign in to comment.