nirodg / easyrs Goto Github PK
View Code? Open in Web Editor NEWThis library provides an easy way to test the basic CRUD operation for your endpoints. The tests can be executed within Arquillian or as a Singleton application
License: MIT License
This library provides an easy way to test the basic CRUD operation for your endpoints. The tests can be executed within Arquillian or as a Singleton application
License: MIT License
@Generated
before the classIt should look like
package com.dorinbrage.github.jme.note.rest;
// Here the imports
@SuppressWarnings("unchecked")
@Generated(
value = "com.dbrage.lib.easyrs.processor",
date = "2017-02-20T18:16:47+0100",
comments = "version: 1.0.0.CR2, compiler: javac, environment: Java 1.8.0_65 (Oracle Corporation)"
)
public class NoteRestTestEndpoint extends Container<NoteDto, NoteRest> {
// Here you can define your global variables
@Before
public void setUp() {
// Here you can initialize your variables
}
@Test
public void getAll() {
List<NoteDto> entities = (ArrayList<NoteDto>) getData(GET_ALL);
List<NoteDto> fetchedEntities = (ArrayList<NoteDto>) getClient().getAll();
Assert.assertEquals(entities.size(), fetchedEntities.size());
}
@Test
public void create() {
NoteDto entity = (NoteDto) getData(PUT);
Assert.assertNotNull(entity);
NoteDto fetchedEntity = (NoteDto) getClient().put(entity);
Assert.assertNotNull(fetchedEntity);
Assert.assertEquals(entity, fetchedEntity);
}
@Test
public void update() {
NoteDto entity = (NoteDto) getData(POST);
Assert.assertNotNull(entity);
entity = (NoteDto) getClient().put(entity);
Assert.assertNotNull(entity);
NoteDto fetchedEntity = (NoteDto) getClient().post(entity.getGuid(), entity);
Assert.assertNotNull(fetchedEntity);
Assert.assertEquals(entity, fetchedEntity);
}
@Test
public void delete() {
NoteDto entity = (NoteDto) getData(DELETE);
Assert.assertNotNull(entity);
entity = (NoteDto) getClient().put(entity);
Assert.assertNotNull(entity);
NoteDto fetchedEntity = (NoteDto) getClient().delete(entity.getGuid());
Assert.assertNull(fetchedEntity);
}
}
Defines the guideline in order to do a create branches, code formatting, etc
During the compile time it should be displayed relevant data regarding the annotated class.
Here is how it should look like:
[INFO] Compiling 1 source file to C:\code\github\earyrs-proc\mytestproject\target\test-classes
...
[EasyRS] Generating UserRestTestEnpoint.class [ GET_ALL, GET, PUT, POST, DELETE ]
[EasyRS] Generating BookRestTestEnpoint.class [ GET, DELETE ]
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
The project shall be integrated with Zappr to keep the good practice so we will enforce the guideline before a pull request is done.
Update the documentation
Short description: Provide a single/multiple execution mode
Implement two classes :
When the class is generated, it might contain errors due the DTO to be tested might contain or not getGuid() or either getId(), so if it doesn't contain such field it will complain.
Add Gitter badge to RADME file
Implement/refactor the Client so it's able to make the request for secured hosts
private String username;
private String password;
// GETTERS and SETTERS
Short description: Implement function to map a json file to an object via reflection.
As a first approach it should map primitive and simple objects (String, Long, Double), then map Lists, ArrayList and similar.
Due each method is an independent test each method we should persist first the data and afterwords proceed to execute the proper crud operation depending on the method which is being tested.
An example about how getAll() shoud look like
@Test
@InSequence(1)
public void getAll() {
UserDto persistDto = Data.importData();
persistDto = client.put(dto);
Assert.assertNotNull(persistDto);
List<UserDto> getPersistedEntities = client.get();
Assert.assertNotNull(getPersistedEntities);
Assert.assertEquals(1, getPersistedEntities.size());
}
In order to test the Entity it must exist some data in order to proceed with the testing.
Would be a good approach to provide a JSON file for each Entity which will contain data ?
For each class with uses the custom annotation, it will generate automatically the java class .
The generated file will extend the abstract class which contains all the configuration in order to be deployed and executed by Arquillian
The annotated class should looks like
@IndependentTest(dto = UserDto.class, endpoint = UserEndpoint.class)
public class User {
// Leave the class empty
}
Where UserDTO should be our entity to be tested
public class UserDto {
String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Where UserEndpoint is our interface with all the path. It should contain at least the basic CRUD operations which are: GET, PUT, POST and DELETE
@Path("/users")
public interface UserEndpoint {
// [...]
@GET
@Path("/")
public List<UserDto> getAll();
// [...]
}
A jaxrs client is needed in order to do
GET It should return single and multiple results
PUT It should return single result
POST It should return the update result
DELETE Shall this return boolean or better check the 200 header response ?
The RestClient always appoints to the same direction, instead of appointing based on the endpoint which has to be tested.
Declare endpoint as a required field on EnpointTest's annotation and fetch the final endpoint throw Path's annotation
Add missing implementation so it's possible to use tokens against the endpoints
The generated class should be executed either with Arquillian or as a Singleton application
It should initialise the jaxrs client
private Client<UserDto> client;
@Before
public void setUp() {
client = new Client<>();
}
Get the followed system properties in order to configure properly the client and initialize inside the Before's method:
The created JSON files should be created only once so there is no need to fill them in each time the project is compiled.
Fix all comments where old groupId appears com.dbrage
Unused imports
Rename packaged using the common sense and good practice
Check unused dependencies
Due it gonna be publish onto Sonatype's repository and the new requested groupId was approved therefore is will be changed to com.dorinbrage and the artifact will be easyrs
<groupId>com.dorinbrage</groupId>
<artifactId>easyrs</artifactId>
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.