release 0.1 #31

Manually merged
noemi3 merged 6 commits from release/0.1 into develop 2020-01-18 16:40:04 +00:00
18 changed files with 143 additions and 111 deletions
Showing only changes of commit e0d8f87dd6 - Show all commits

View File

@ -65,7 +65,7 @@ class LoginActivity : AppCompatActivity() {
override fun onResponse(call: Call<UserPrototype>, response: Response<UserPrototype>) { override fun onResponse(call: Call<UserPrototype>, response: Response<UserPrototype>) {
if (response.code() != 200) { if (response.code() != HTTP_CODE_OK) {
Toast.makeText( Toast.makeText(
applicationContext, applicationContext,
R.string.login_wrong_field, R.string.login_wrong_field,
@ -93,5 +93,6 @@ class LoginActivity : AppCompatActivity() {
companion object { companion object {
const val LOGIN_OK = 0 const val LOGIN_OK = 0
const val LOGIN_ERROR = 1 const val LOGIN_ERROR = 1
const val HTTP_CODE_OK = 200
} }
} }

View File

@ -54,7 +54,6 @@
<property name="tokens" <property name="tokens"
value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/> value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
</module> </module>
<module name="NeedBraces"/>
<module name="LeftCurly"/> <module name="LeftCurly"/>
<module name="RightCurly"> <module name="RightCurly">
<property name="id" value="RightCurlySame"/> <property name="id" value="RightCurlySame"/>
@ -191,7 +190,6 @@
<property name="allowedAbbreviationLength" value="1"/> <property name="allowedAbbreviationLength" value="1"/>
</module> </module>
<module name="OverloadMethodsDeclarationOrder"/> <module name="OverloadMethodsDeclarationOrder"/>
<module name="VariableDeclarationUsageDistance"/>
<module name="CustomImportOrder"> <module name="CustomImportOrder">
<property name="sortImportsInGroupAlphabetically" value="true"/> <property name="sortImportsInGroupAlphabetically" value="true"/>
<property name="separateLineBetweenGroups" value="true"/> <property name="separateLineBetweenGroups" value="true"/>

View File

@ -1,13 +1,17 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import java.util.List;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Board; import it.unisannio.ding.ids.wedroid.wrapper.entity.Board;
import it.unisannio.ding.ids.wedroid.wrapper.entity.BoardPrototype; import it.unisannio.ding.ids.wedroid.wrapper.entity.BoardPrototype;
import it.unisannio.ding.ids.wedroid.wrapper.entity.LabelPrototype; import it.unisannio.ding.ids.wedroid.wrapper.entity.LabelPrototype;
import it.unisannio.ding.ids.wedroid.wrapper.entity.MemberPermission; import it.unisannio.ding.ids.wedroid.wrapper.entity.MemberPermission;
import java.util.List;
import retrofit2.Call; import retrofit2.Call;
import retrofit2.http.*; import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
public interface BoardService { public interface BoardService {

View File

@ -1,10 +1,14 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Comment; import it.unisannio.ding.ids.wedroid.wrapper.entity.Comment;
import retrofit2.Call;
import retrofit2.http.*;
import java.util.List; import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface CardCommentService { public interface CardCommentService {

View File

@ -1,10 +1,17 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Card; import it.unisannio.ding.ids.wedroid.wrapper.entity.Card;
import retrofit2.Call;
import retrofit2.http.*;
import java.util.List; import java.util.List;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
public interface CardService { public interface CardService {

View File

@ -4,10 +4,16 @@ import it.unisannio.ding.ids.wedroid.wrapper.entity.Checklist;
import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistItem; import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistItem;
import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistItemStatus; import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistItemStatus;
import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistPrototype; import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistPrototype;
import retrofit2.Call;
import retrofit2.http.*;
import java.util.List; import java.util.List;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
public interface ChecklistService { public interface ChecklistService {

View File

@ -1,11 +1,14 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import it.unisannio.ding.ids.wedroid.wrapper.entity.WList; import it.unisannio.ding.ids.wedroid.wrapper.entity.WList;
import retrofit2.Call;
import retrofit2.http.*;
import java.util.List; import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface ListService { public interface ListService {

View File

@ -1,10 +1,14 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Swimlane; import it.unisannio.ding.ids.wedroid.wrapper.entity.Swimlane;
import retrofit2.Call;
import retrofit2.http.*;
import java.util.List; import java.util.List;
import retrofit2.Call;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface SwimlanesService { public interface SwimlanesService {
/** /**

View File

@ -3,10 +3,16 @@ package it.unisannio.ding.ids.wedroid.wrapper.api;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Action; import it.unisannio.ding.ids.wedroid.wrapper.entity.Action;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Board; import it.unisannio.ding.ids.wedroid.wrapper.entity.Board;
import it.unisannio.ding.ids.wedroid.wrapper.entity.User; import it.unisannio.ding.ids.wedroid.wrapper.entity.User;
import retrofit2.Call;
import retrofit2.http.*;
import java.util.List; import java.util.List;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Path;
public interface UserService { public interface UserService {
@ -44,7 +50,7 @@ public interface UserService {
Call<User> delete(@Path("user") String userId); Call<User> delete(@Path("user") String userId);
/******************** Don't work ****************************************************/ /******************** Don't work ****************************************************/
@FormUrlEncoded @FormUrlEncoded
@POST("api/users") @POST("api/users")

View File

@ -8,7 +8,7 @@ public class Card {
//Constructor for add card //Constructor for add card
public Card(String authorId, String title, String swimlaneId, String description) { public Card(String authorId, String title, String swimlaneId, String description) {
this.authorId= authorId; this.authorId = authorId;
this.title = title; this.title = title;
this.swimlaneId = swimlaneId; this.swimlaneId = swimlaneId;
this.description = description; this.description = description;

View File

@ -4,7 +4,7 @@ public class MemberPermission {
/** /**
* The user is an admin of the board * The user is an admin of the board
*/ */
public final static MemberPermission ADMIN = new MemberPermission( public static final MemberPermission ADMIN = new MemberPermission(
true, true,
false, false,
false false
@ -13,7 +13,7 @@ public class MemberPermission {
/** /**
* The use is an normal member of the board * The use is an normal member of the board
*/ */
public final static MemberPermission NORMAL = new MemberPermission( public static final MemberPermission NORMAL = new MemberPermission(
false, false,
false, false,
false false
@ -22,7 +22,7 @@ public class MemberPermission {
/** /**
* The user isn't allowed to make comments on the board * The user isn't allowed to make comments on the board
*/ */
public final static MemberPermission NO_COMMENTS = new MemberPermission( public static final MemberPermission NO_COMMENTS = new MemberPermission(
false, false,
true, true,
false false
@ -31,7 +31,7 @@ public class MemberPermission {
/** /**
* The user is only allowed to make comments on the board * The user is only allowed to make comments on the board
*/ */
public final static MemberPermission COMMENT_ONLY = new MemberPermission( public static final MemberPermission COMMENT_ONLY = new MemberPermission(
false, false,
false, false,
true true

View File

@ -1,10 +1,18 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Board; import it.unisannio.ding.ids.wedroid.wrapper.entity.Board;
import it.unisannio.ding.ids.wedroid.wrapper.entity.BoardBackgroundColor; import it.unisannio.ding.ids.wedroid.wrapper.entity.BoardBackgroundColor;
import it.unisannio.ding.ids.wedroid.wrapper.entity.BoardPermission; import it.unisannio.ding.ids.wedroid.wrapper.entity.BoardPermission;
import it.unisannio.ding.ids.wedroid.wrapper.entity.BoardPrototype; import it.unisannio.ding.ids.wedroid.wrapper.entity.BoardPrototype;
import it.unisannio.ding.ids.wedroid.wrapper.entity.PresentParentTask; import it.unisannio.ding.ids.wedroid.wrapper.entity.PresentParentTask;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.MockWebServer;
import org.junit.After; import org.junit.After;
@ -13,12 +21,6 @@ import org.junit.Test;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import static org.junit.Assert.*;
public class BoardServiceTest { public class BoardServiceTest {
private MockWebServer mockWebServer = new MockWebServer(); private MockWebServer mockWebServer = new MockWebServer();
private BoardService service = null; private BoardService service = null;
@ -59,8 +61,8 @@ public class BoardServiceTest {
mockWebServer.enqueue(response); mockWebServer.enqueue(response);
try { try {
List<Board> boards = service.getPublicBoards(). List<Board> boards = service.getPublicBoards()
execute().body(); .execute().body();
assertNotNull(boards); assertNotNull(boards);
assertEquals(2, boards.size()); assertEquals(2, boards.size());

View File

@ -1,6 +1,12 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Comment; import it.unisannio.ding.ids.wedroid.wrapper.entity.Comment;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.MockWebServer;
import org.junit.After; import org.junit.After;
@ -9,13 +15,6 @@ import org.junit.Test;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class CardCommentServiceTest { public class CardCommentServiceTest {
private MockWebServer mockWebServer = new MockWebServer(); private MockWebServer mockWebServer = new MockWebServer();
private CardCommentService service = null; private CardCommentService service = null;
@ -110,17 +109,17 @@ public class CardCommentServiceTest {
} }
} }
private final static String COMMENT_1 = "{" + private static final String COMMENT_1 = "{" +
"\"_id\":\"zwzAgjHdW4fNJ9YLc\"," + "\"_id\":\"zwzAgjHdW4fNJ9YLc\"," +
"\"comment\":\"comment 1\"," + "\"comment\":\"comment 1\"," +
"\"authorId\":\"Si69gNgkJfQuk6uiJ\"" + "\"authorId\":\"Si69gNgkJfQuk6uiJ\"" +
"}"; "}";
private final static String COMMENT_2 = "{" + private static final String COMMENT_2 = "{" +
"\"_id\":\"zwzAgjHdW4fNJ9YLt\"," + "\"_id\":\"zwzAgjHdW4fNJ9YLt\"," +
"\"comment\":\"comment 2\"," + "\"comment\":\"comment 2\"," +
"\"authorId\":\"Si69gNgkJfQuk6uiJ\"" + "\"authorId\":\"Si69gNgkJfQuk6uiJ\"" +
"}"; "}";
private final static String COMMENT_3 = "{" + private static final String COMMENT_3 = "{" +
"\"_id\":\"DofhD9v96DbX7Wirp\"," + "\"_id\":\"DofhD9v96DbX7Wirp\"," +
"\"userId\":\"Si69gNgkJfQuk6uiJ\"," + "\"userId\":\"Si69gNgkJfQuk6uiJ\"," +
"\"text\":\"commento api\"," + "\"text\":\"commento api\"," +

View File

@ -1,22 +1,20 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Card;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Card;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class CardServiceTest { public class CardServiceTest {
private MockWebServer mockWebServer = new MockWebServer(); private MockWebServer mockWebServer = new MockWebServer();
private CardService service = null; private CardService service = null;
@ -45,7 +43,7 @@ public class CardServiceTest {
} }
@Test @Test
public void getAllCardsTest(){ public void getAllCardsTest() {
MockResponse response = new MockResponse() MockResponse response = new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_OK) .setResponseCode(HttpURLConnection.HTTP_OK)
.setBody( .setBody(
@ -56,8 +54,8 @@ public class CardServiceTest {
mockWebServer.enqueue(response); mockWebServer.enqueue(response);
try { try {
List<Card> cards = service.getAllCards("oKthRbLqoXZr5NNua","iA6pmp6fENvF7AaTX"). List<Card> cards = service.getAllCards("oKthRbLqoXZr5NNua","iA6pmp6fENvF7AaTX")
execute().body(); .execute().body();
assertNotNull(cards); assertNotNull(cards);
assertEquals("Numbero of card not ok",2, cards.size()); assertEquals("Numbero of card not ok",2, cards.size());
@ -75,7 +73,7 @@ public class CardServiceTest {
} }
@Test @Test
public void getCardTest(){ public void getCardTest() {
MockResponse response = new MockResponse() MockResponse response = new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_OK) .setResponseCode(HttpURLConnection.HTTP_OK)
.setBody(card); .setBody(card);
@ -84,12 +82,12 @@ public class CardServiceTest {
"oKthRbLqoXZr5NNua","iA6pmp6fENvF7AaTX","J5a86fPe2DhqN3QbF") "oKthRbLqoXZr5NNua","iA6pmp6fENvF7AaTX","J5a86fPe2DhqN3QbF")
.execute().body(); .execute().body();
assertNotNull(card); assertNotNull(card);
assertEquals("J5a86fPe2DhqN3QbF", card.getId() ); assertEquals("J5a86fPe2DhqN3QbF", card.getId());
assertEquals("patch", card.getTitle()); assertEquals("patch", card.getTitle());
assertEquals("iA6pmp6fENvF7AaTX", card.getListId()); assertEquals("iA6pmp6fENvF7AaTX", card.getListId());
assertEquals("2019-11-10T11:21:31.116Z", card.getCreatedAt().toString()); assertEquals("2019-11-10T11:21:31.116Z", card.getCreatedAt().toString());
}catch (IOException e){ } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
mockWebServer.enqueue(response); mockWebServer.enqueue(response);
@ -97,7 +95,7 @@ public class CardServiceTest {
} }
@Test @Test
public void newCardTest(){ public void newCardTest() {
MockResponse response = new MockResponse() MockResponse response = new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_OK) .setResponseCode(HttpURLConnection.HTTP_OK)
.setBody( .setBody(
@ -133,7 +131,7 @@ public class CardServiceTest {
.execute().body(); .execute().body();
assertNotNull(cards); assertNotNull(cards);
assertEquals(3, cards.size()); assertEquals(3, cards.size());
for(int i = 0; i < cards.size(); i++){ for (int i = 0; i < cards.size(); i++) {
assertEquals("J5a86fPe2DhqN3QbF" + i, cards.get(i).getId()); assertEquals("J5a86fPe2DhqN3QbF" + i, cards.get(i).getId());
assertEquals("card " + i, cards.get(i).getTitle()); assertEquals("card " + i, cards.get(i).getTitle());
assertEquals("iA6pmp6fENvF7AaTX" + i, cards.get(i).getListId()); assertEquals("iA6pmp6fENvF7AaTX" + i, cards.get(i).getListId());
@ -159,9 +157,9 @@ public class CardServiceTest {
} }
private static final String card = private static final String card =
"{"+ "{" +
"\"_id\":\"J5a86fPe2DhqN3QbF\"," + "\"_id\":\"J5a86fPe2DhqN3QbF\"," +
"\"title\":\"title1\","+ "\"title\":\"title1\"," +
"\"boardId\":\"oKthRbLqoXZr5NNua\"," + "\"boardId\":\"oKthRbLqoXZr5NNua\"," +
"\"listId\":\"iA6pmp6fENvF7AaTX\"," + "\"listId\":\"iA6pmp6fENvF7AaTX\"," +
"\"description\":\"proof\"," + "\"description\":\"proof\"," +

View File

@ -1,9 +1,15 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertEquals;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Checklist; import it.unisannio.ding.ids.wedroid.wrapper.entity.Checklist;
import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistItem; import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistItem;
import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistItemStatus; import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistItemStatus;
import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistPrototype; import it.unisannio.ding.ids.wedroid.wrapper.entity.ChecklistPrototype;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.MockWebServer;
import org.junit.After; import org.junit.After;
@ -12,12 +18,6 @@ import org.junit.Test;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import static org.junit.Assert.*;
public class ChecklistServiceTest { public class ChecklistServiceTest {
private MockWebServer mockWebServer = new MockWebServer(); private MockWebServer mockWebServer = new MockWebServer();
private ChecklistService service = null; private ChecklistService service = null;
@ -59,8 +59,8 @@ public class ChecklistServiceTest {
try { try {
List<Checklist> checklists = service.getAllChecklists( List<Checklist> checklists = service.getAllChecklists(
"board id", "card id" "board id", "card id"
). )
execute().body(); .execute().body();
assertNotNull(checklists); assertNotNull(checklists);
assertEquals(2, checklists.size()); assertEquals(2, checklists.size());

View File

@ -1,6 +1,12 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
import it.unisannio.ding.ids.wedroid.wrapper.entity.WList; import it.unisannio.ding.ids.wedroid.wrapper.entity.WList;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.MockWebServer;
import org.junit.After; import org.junit.After;
@ -9,12 +15,6 @@ import org.junit.Test;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import static org.junit.Assert.*;
public class ListServiceTest { public class ListServiceTest {
private MockWebServer mockWebServer = new MockWebServer(); private MockWebServer mockWebServer = new MockWebServer();
private ListService service = null; private ListService service = null;

View File

@ -1,7 +1,13 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assert.assertEquals;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Color; import it.unisannio.ding.ids.wedroid.wrapper.entity.Color;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Swimlane; import it.unisannio.ding.ids.wedroid.wrapper.entity.Swimlane;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.MockWebServer;
import org.junit.After; import org.junit.After;
@ -10,12 +16,6 @@ import org.junit.Test;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import static org.junit.Assert.*;
public class SwimlanesServiceTest { public class SwimlanesServiceTest {
private MockWebServer mockWebServer = new MockWebServer(); private MockWebServer mockWebServer = new MockWebServer();
private SwimlanesService service = null; private SwimlanesService service = null;
@ -62,6 +62,7 @@ public class SwimlanesServiceTest {
for (int i = 0; i < 2; i++) for (int i = 0; i < 2; i++)
assertEquals("title " + (i + 1), lists.get(i).getTitle()); assertEquals("title " + (i + 1), lists.get(i).getTitle());
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -108,8 +109,8 @@ public class SwimlanesServiceTest {
} }
} }
final static String SWIMLANE_1 = "{\n\"_id\": \"BS4AA79YABBCpDDau\",\n\"title\": \"title 1\"\n}"; static final String SWIMLANE_1 = "{\n\"_id\": \"BS4AA79YABBCpDDau\",\n\"title\": \"title 1\"\n}";
final static String SWIMLANE_2 = "{" + static final String SWIMLANE_2 = "{" +
"\"_id\":\"JNmpXKCupbtyPkYMG\"," + "\"_id\":\"JNmpXKCupbtyPkYMG\"," +
"\"title\":\"title 2\"," + "\"title\":\"title 2\"," +
"\"boardId\":\"TtjXrJyvPkG3xsbkw\"," + "\"boardId\":\"TtjXrJyvPkG3xsbkw\"," +

View File

@ -1,25 +1,25 @@
package it.unisannio.ding.ids.wedroid.wrapper.api; package it.unisannio.ding.ids.wedroid.wrapper.api;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import it.unisannio.ding.ids.wedroid.wrapper.entity.Service; import it.unisannio.ding.ids.wedroid.wrapper.entity.Service;
import it.unisannio.ding.ids.wedroid.wrapper.entity.User; import it.unisannio.ding.ids.wedroid.wrapper.entity.User;
import it.unisannio.ding.ids.wedroid.wrapper.entity.UserEmail; import it.unisannio.ding.ids.wedroid.wrapper.entity.UserEmail;
import it.unisannio.ding.ids.wedroid.wrapper.entity.UserProfile; import it.unisannio.ding.ids.wedroid.wrapper.entity.UserProfile;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer; import okhttp3.mockwebserver.MockWebServer;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.*;
import retrofit2.Call;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
import javax.jws.soap.SOAPBinding;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.util.List;
public class UserServiceTest { public class UserServiceTest {
private MockWebServer mockWebServer = new MockWebServer(); private MockWebServer mockWebServer = new MockWebServer();
private UserService service = null; private UserService service = null;
@ -49,7 +49,7 @@ public class UserServiceTest {
} }
@Test @Test
public void getAllUsersTest(){ public void getAllUsersTest() {
MockResponse response = new MockResponse() MockResponse response = new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_OK) .setResponseCode(HttpURLConnection.HTTP_OK)
.setBody( .setBody(
@ -59,7 +59,7 @@ public class UserServiceTest {
); );
mockWebServer.enqueue(response); mockWebServer.enqueue(response);
try{ try {
List<User> users = service.getAllUser().execute().body(); List<User> users = service.getAllUser().execute().body();
assertNotNull(users); assertNotNull(users);
assertEquals("Si69gNgkJfQuk6uiJ", users.get(0).getId()); assertEquals("Si69gNgkJfQuk6uiJ", users.get(0).getId());
@ -68,14 +68,13 @@ public class UserServiceTest {
assertEquals("noemi", users.get(1).getUsername()); assertEquals("noemi", users.get(1).getUsername());
assertEquals("jPdkf3a9bmfZWx3GR", users.get(2).getId()); assertEquals("jPdkf3a9bmfZWx3GR", users.get(2).getId());
assertEquals("umberto", users.get(2).getUsername()); assertEquals("umberto", users.get(2).getUsername());
} } catch (IOException e) {
catch (IOException e){
e.printStackTrace(); e.printStackTrace();
} }
} }
@Test @Test
public void getUser(){ public void getUser() {
MockResponse response = new MockResponse() MockResponse response = new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_OK) .setResponseCode(HttpURLConnection.HTTP_OK)
.setBody(user1); .setBody(user1);
@ -114,7 +113,7 @@ public class UserServiceTest {
} }
@Test @Test
public void getCurrentUser(){ public void getCurrentUser() {
MockResponse mockResponse = new MockResponse() MockResponse mockResponse = new MockResponse()
.setResponseCode(HttpURLConnection.HTTP_OK) .setResponseCode(HttpURLConnection.HTTP_OK)
.setBody(user2); .setBody(user2);
@ -155,7 +154,7 @@ public class UserServiceTest {
"\"profile\":{\"boardView\":\"board-view-swimlanes\",\"templatesBoardId\":\"eLvE8FnqvACfC9Rtb\"," + "\"profile\":{\"boardView\":\"board-view-swimlanes\",\"templatesBoardId\":\"eLvE8FnqvACfC9Rtb\"," +
"\"cardTemplatesSwimlaneId\":\"zo82BZYxFTNBpb7jX\",\"listTemplatesSwimlaneId\":\"Kja32A85P2HADWKFA\"," + "\"cardTemplatesSwimlaneId\":\"zo82BZYxFTNBpb7jX\",\"listTemplatesSwimlaneId\":\"Kja32A85P2HADWKFA\"," +
"\"boardTemplatesSwimlaneId\":\"j6ZuPbwaN9nsCDxyS\",\"listSortBy\":\"-modifiedAt\"}," + "\"boardTemplatesSwimlaneId\":\"j6ZuPbwaN9nsCDxyS\",\"listSortBy\":\"-modifiedAt\"}," +
"\"createdAt\":\"2019-10-14T18:14:38.249Z\","+ "\"createdAt\":\"2019-10-14T18:14:38.249Z\"," +
"\"modifiedAt\":\"2019-11-09T17:55:36.976Z\"," + "\"modifiedAt\":\"2019-11-09T17:55:36.976Z\"," +
"\"services\":{\n" + "\"services\":{\n" +
" \"password\":{\n" + " \"password\":{\n" +
@ -185,7 +184,7 @@ public class UserServiceTest {
"}\n" + "}\n" +
"}"; "}";
private final String user2 = "{" + private static final String user2 = "{" +
"\"_id\":\"jPdkf3a9bmfZWx3GR\"," + "\"_id\":\"jPdkf3a9bmfZWx3GR\"," +
"\"createdAt\":\"2019-10-14T18:14:38.249Z\"," + "\"createdAt\":\"2019-10-14T18:14:38.249Z\"," +
"\"username\":\"umberto\"," + "\"username\":\"umberto\"," +