Skip to content

Commit

Permalink
Issue 952 remove testng (#1004)
Browse files Browse the repository at this point in the history
* Remove testng dependencies for all non suite tests

* Change Before and After Suite method to Before and After All

* Remove pom dependencies

* add junit engine dependency

* Remove testng xml suites
  • Loading branch information
Chandrasekar-Rajasekar authored and aklish committed Oct 10, 2019
1 parent f6c4302 commit 45adbb8
Show file tree
Hide file tree
Showing 33 changed files with 351 additions and 448 deletions.
5 changes: 2 additions & 3 deletions elide-contrib/elide-swagger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;

import org.testng.Assert;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;

import io.swagger.converter.ModelConverters;
import io.swagger.models.Model;
Expand All @@ -25,7 +26,7 @@

import java.util.Map;


@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class JsonApiModelResolverTest {

private static final String KEY_BOOK = "book";
Expand All @@ -39,7 +40,7 @@ public class JsonApiModelResolverTest {

private ModelConverters converters;

@BeforeSuite
@BeforeAll
public void setup() {
EntityDictionary dictionary = new EntityDictionary(Maps.newHashMap());

Expand All @@ -58,102 +59,102 @@ public void testBookPermissions() {
ObjectProperty relationships = getObjectProperty(KEY_BOOK, "relationships");

String entityPermissions = entity.getDescription();
Assert.assertEquals(entityPermissions,
"Create Permissions : (Principal is author)\nDelete Permissions : (Deny All)");
Assertions.assertEquals("Create Permissions : (Principal is author)\nDelete Permissions : (Deny All)",
entityPermissions);

String titlePermissions = attributes.getProperties().get("title").getDescription();
Assert.assertEquals(titlePermissions, "Read Permissions : (Principal is author OR Principal is publisher)");
Assertions.assertEquals("Read Permissions : (Principal is author OR Principal is publisher)", titlePermissions);

String publisherPermissions = relationships.getProperties().get("publisher").getDescription();
Assert.assertEquals(publisherPermissions,
"Read Permissions : (Principal is author OR Principal is publisher)\n"
+ "Update Permissions : (Principal is publisher)");
Assertions.assertEquals("Read Permissions : (Principal is author OR Principal is publisher)\n"
+ "Update Permissions : (Principal is publisher)",
publisherPermissions);
}

@Test
public void testModelResolution() {
ObjectProperty attributes = getObjectProperty(KEY_PUBLISHER, "attributes");
ObjectProperty relationships = getObjectProperty(KEY_PUBLISHER, "relationships");

Assert.assertEquals(attributes.getProperties().size(), 3);
Assert.assertEquals(relationships.getProperties().size(), 2);
Assert.assertTrue(attributes.getProperties().containsKey("billingAddress"));
Assert.assertTrue(attributes.getProperties().containsKey("billingCodes"));
Assert.assertTrue(relationships.getProperties().containsKey("books"));
Assert.assertTrue(relationships.getProperties().containsKey("exclusiveAuthors"));
Assertions.assertEquals(3, attributes.getProperties().size());
Assertions.assertEquals(2, relationships.getProperties().size());
Assertions.assertTrue(attributes.getProperties().containsKey("billingAddress"));
Assertions.assertTrue(attributes.getProperties().containsKey("billingCodes"));
Assertions.assertTrue(relationships.getProperties().containsKey("books"));
Assertions.assertTrue(relationships.getProperties().containsKey("exclusiveAuthors"));
}

@Test
public void testDescription() {
ObjectProperty attributes = getObjectProperty(KEY_PUBLISHER, "attributes");

String phoneDescription = attributes.getProperties().get("phone").getDescription();
Assert.assertEquals(phoneDescription, "Phone number");
Assertions.assertEquals("Phone number", phoneDescription);
}

@Test
public void testNoDescriptionWithoutAnnotation() {
ObjectProperty attributes = getObjectProperty(KEY_AUTHOR, "attributes");

Object nameDescription = attributes.getProperties().get("name").getDescription();
Assert.assertNull(nameDescription);
Assertions.assertNull(nameDescription);
}

@Test
public void testNoDescriptionWhenNotProvided() {
ObjectProperty attributes = getObjectProperty(KEY_AUTHOR, "attributes");

Object phoneDescription = attributes.getProperties().get("phone").getDescription();
Assert.assertNull(phoneDescription);
Assertions.assertNull(phoneDescription);
}

@Test
public void testExample() {
ObjectProperty attributes = getObjectProperty(KEY_PUBLISHER, "attributes");

Object phoneExample = attributes.getProperties().get("phone").getExample();
Assert.assertEquals(phoneExample, "555-000-1111");
Assertions.assertEquals("555-000-1111", phoneExample);
}

@Test
public void testNoExampleWithoutAnnotation() {
ObjectProperty attributes = getObjectProperty(KEY_AUTHOR, "attributes");

Object nameExample = attributes.getProperties().get("name").getExample();
Assert.assertNull(nameExample);
Assertions.assertNull(nameExample);
}

@Test
public void testNoExampleWhenNotProvided() {
ObjectProperty attributes = getObjectProperty(KEY_AUTHOR, "attributes");

Object phoneExample = attributes.getProperties().get("phone").getExample();
Assert.assertNull(phoneExample);
Assertions.assertNull(phoneExample);
}

@Test
public void testConcatenatedDescriptionAndPermissions() {
ObjectProperty attributes = getObjectProperty(KEY_BOOK, "attributes");

String yearDescription = attributes.getProperties().get("year").getDescription();
Assert.assertEquals(yearDescription,
"Year published\nRead Permissions : (Principal is author OR Principal is publisher)");
Assertions.assertEquals("Year published\nRead Permissions : (Principal is author OR Principal is publisher)",
yearDescription);
}

@Test
public void testRequired() {
ObjectProperty attributes = getObjectProperty(KEY_BOOK, "attributes");

boolean titleRequired = attributes.getProperties().get("title").getRequired();
Assert.assertTrue(titleRequired);
Assertions.assertTrue(titleRequired);
}

@Test
public void testReadOnly() {
ObjectProperty attributes = getObjectProperty(KEY_BOOK, "attributes");

Boolean titleReadOnly = attributes.getProperties().get("year").getReadOnly();
Assert.assertTrue(titleReadOnly);
Assertions.assertTrue(titleReadOnly);
}

private Resource getModel(String entityKey) {
Expand Down

0 comments on commit 45adbb8

Please sign in to comment.