diff --git a/app/src/commonTest/java/org/schulcloud/mobile/test/common/TestDataFactory.java b/app/src/commonTest/java/org/schulcloud/mobile/test/common/TestDataFactory.java index e2fd8717..e627d0d0 100644 --- a/app/src/commonTest/java/org/schulcloud/mobile/test/common/TestDataFactory.java +++ b/app/src/commonTest/java/org/schulcloud/mobile/test/common/TestDataFactory.java @@ -1,11 +1,13 @@ package org.schulcloud.mobile.test.common; +import org.schulcloud.mobile.data.model.Device; +import org.schulcloud.mobile.data.model.Event; +import org.schulcloud.mobile.data.model.User; + import java.util.ArrayList; import java.util.List; import java.util.UUID; -import org.schulcloud.mobile.data.model.User; - /** * Factory class that makes instances of data models with random field values. * The aim of this class is to help setting up test fixtures. @@ -32,4 +34,34 @@ public static List makeListUsers(int number) { } return users; } + + public static Event makeEvent(String uniqueSuffix) { + Event e = new Event(); + + return e; + } + + public static List makeListEvents(int number) { + List events = new ArrayList<>(); + for (int i = 0; i < number; i++) { + events.add(makeEvent(String.valueOf(i))); + } + return events; + } + + + public static Device makeDevice(String uniqueSuffix) { + Device d = new Device(); + + return d; + } + + public static List makeListDevices(int number) { + List devices = new ArrayList<>(); + for (int i = 0; i < number; i++) { + devices.add(makeDevice(String.valueOf(i))); + } + return devices; + } + } \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/SettingsPresenterTest.java b/app/src/test/java/org/schulcloud/mobile/SettingsPresenterTest.java new file mode 100644 index 00000000..df1cd040 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/SettingsPresenterTest.java @@ -0,0 +1,104 @@ +package org.schulcloud.mobile; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.runners.MockitoJUnitRunner; +import org.schulcloud.mobile.data.DataManager; +import org.schulcloud.mobile.data.model.Device; +import org.schulcloud.mobile.data.model.Event; +import org.schulcloud.mobile.test.common.TestDataFactory; +import org.schulcloud.mobile.ui.settings.SettingsMvpView; +import org.schulcloud.mobile.ui.settings.SettingsPresenter; +import org.schulcloud.mobile.util.RxSchedulersOverrideRule; + +import java.util.Collections; +import java.util.List; + +import rx.Observable; + +import static org.mockito.Matchers.anyListOf; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.powermock.api.mockito.PowerMockito.doReturn; + +@RunWith(MockitoJUnitRunner.class) +public class SettingsPresenterTest { + + @Rule + public final RxSchedulersOverrideRule mOverrideSchedulersRule = new RxSchedulersOverrideRule(); + @Mock + SettingsMvpView mMockSettingsMvpView; + @Mock + DataManager mMockDataManager; + private SettingsPresenter mSettingsPresenter; + + @Before + public void setUp() { + mSettingsPresenter = new SettingsPresenter(mMockDataManager); + mSettingsPresenter.attachView(mMockSettingsMvpView); + } + + @After + public void tearDown() { + mSettingsPresenter.detachView(); + } + + @Test + public void loadEventsReturnsEvents() { + List events = TestDataFactory.makeListEvents(10); + doReturn(Observable.just(events)) + .when(mMockDataManager) + .getEvents(); + + mSettingsPresenter.loadEvents(); + verify(mMockSettingsMvpView).connectToCalendar(events); + verify(mMockSettingsMvpView, never()).showEventsEmpty(); + } + + @Test + public void loadEventsReturnsEmptyList() { + doReturn(Observable.just(Collections.emptyList())) + .when(mMockDataManager) + .getEvents(); + + mSettingsPresenter.loadEvents(); + verify(mMockSettingsMvpView).showEventsEmpty(); + verify(mMockSettingsMvpView, never()).connectToCalendar(anyListOf(Event.class)); + } + + @Test + public void loadEventsFails() { + doReturn(Observable.error(new RuntimeException())) + .when(mMockDataManager) + .getEvents(); + + mSettingsPresenter.loadEvents(); + verify(mMockSettingsMvpView, never()).showEventsEmpty(); + verify(mMockSettingsMvpView, never()).connectToCalendar(anyListOf(Event.class)); + } + + @Test + public void loadDevices() { + List devices = TestDataFactory.makeListDevices(10); + doReturn(Observable.just(devices)) + .when(mMockDataManager) + .getDevices(); + + mSettingsPresenter.loadDevices(); + verify(mMockSettingsMvpView).showDevices(devices); + } + + @Test + public void loadDevicesFails() { + doReturn(Observable.error(new RuntimeException())) + .when(mMockDataManager) + .getDevices(); + + mSettingsPresenter.loadDevices(); + } + +} diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/AccessTokenTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/AccessTokenTest.java new file mode 100644 index 00000000..946b5bea --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/AccessTokenTest.java @@ -0,0 +1,37 @@ +package org.schulcloud.mobile.data.model; + +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +public class AccessTokenTest { + private static final String ACCESTOKEN = "OHNOACCESS"; + + private AccessToken accessToken; + + @Before + public void setUp() throws Exception { + accessToken = createAccesToken(); + } + + public static AccessToken createAccesToken() { + AccessToken accessToken = new AccessToken(); + accessToken.accessToken = ACCESTOKEN; + + return accessToken; + } + + @Test + public void getAccessToken() throws Exception { + assertEquals(accessToken.getAccessToken(), ACCESTOKEN); + } + + @Test + public void setAccessToken() throws Exception { + accessToken.setAccessToken(ACCESTOKEN); + assertNotNull(accessToken.getAccessToken()); + } + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/CurrentUserTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/CurrentUserTest.java new file mode 100644 index 00000000..30803e8e --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/CurrentUserTest.java @@ -0,0 +1,102 @@ +package org.schulcloud.mobile.data.model; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class CurrentUserTest { + private static final String _ID = "key"; + private static final String FIRSTNAME = "Ernst"; + private static final String LASTNAME = "Haft"; + private static final String EMAIL = "ernst@haft.bla"; + private static final String SCHOOLID = "123214123"; + private static final String DISPLAYNAME = "Ernst Haft"; + + private CurrentUser user; + + @Before + public void setUp() { + user = createNewUser(); + } + + public static CurrentUser createNewUser() { + CurrentUser user = new CurrentUser(); + user.set_id(_ID); + user.setDisplayName(DISPLAYNAME); + user.setSchoolId(SCHOOLID); + user.setLastName(LASTNAME); + user.setFirstName(FIRSTNAME); + user.setEmail(EMAIL); + + return user; + } + + @Test + public void get_id() throws Exception { + assertEquals(user.get_id(), _ID); + } + + @Test + public void set_id() throws Exception { + user.set_id(_ID); + assertNotNull(user.get_id()); + } + + @Test + public void getFirstName() throws Exception { + assertEquals(user.getFirstName(), FIRSTNAME); + } + + @Test + public void setFirstName() throws Exception { + user.setFirstName(FIRSTNAME); + assertNotNull(user.getFirstName()); + } + + @Test + public void getLastName() throws Exception { + assertEquals(user.getLastName(), LASTNAME); + } + + @Test + public void setLastName() throws Exception { + user.setLastName(LASTNAME); + assertNotNull(user.getLastName()); + } + + @Test + public void getEmail() throws Exception { + assertEquals(user.getEmail(), EMAIL); + } + + @Test + public void setEmail() throws Exception { + user.setEmail(EMAIL); + assertNotNull(user.getEmail()); + } + + @Test + public void getSchoolId() throws Exception { + assertEquals(user.getSchoolId(), SCHOOLID); + } + + @Test + public void setSchoolId() throws Exception { + user.setSchoolId(SCHOOLID); + assertNotNull(user.getSchoolId()); + } + + @Test + public void getDisplayName() throws Exception { + assertEquals(user.getDisplayName(), DISPLAYNAME); + } + + @Test + public void setDisplayName() throws Exception { + user.setDisplayName(DISPLAYNAME); + assertNotNull(user.getDisplayName()); + } + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/DeviceTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/DeviceTest.java new file mode 100644 index 00000000..0413b8a2 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/DeviceTest.java @@ -0,0 +1,57 @@ +package org.schulcloud.mobile.data.model; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class DeviceTest { + private static final String _ID = "_ID"; + private static final String TOKEN = "TOKEN"; + private static final String TYPE = "MOBILE"; + private static final String SERVICE = "SERVICE"; + private static final String NAME = "NAME"; + private static final String OS = "MAGIC"; + private static final String STATE = "UNKNOWN"; + private static final String UPDATEDAT = "YESTERDAY"; + private static final String CREATEDAT = "NOW"; + private static final String ACTIVE = "TRUE"; + + private Device device; + + @Before + public void setUp() { + device = createNewDevice(); + } + + @Test + public void testGetProperties() { + assertEquals(device.name, NAME); + assertEquals(device._id, _ID); + assertEquals(device.token, TOKEN); + assertEquals(device.type, TYPE); + assertEquals(device.service, SERVICE); + assertEquals(device.OS, OS); + assertEquals(device.state, STATE); + assertEquals(device.updatedAt, UPDATEDAT); + assertEquals(device.createdAt, CREATEDAT); + assertEquals(device.active, ACTIVE); + } + + public static Device createNewDevice() { + Device device = new Device(); + device.name = NAME; + device._id = _ID; + device.token = TOKEN; + device.type = TYPE; + device.service = SERVICE; + device.OS = OS; + device.state = STATE; + device.createdAt = CREATEDAT; + device.updatedAt = UPDATEDAT; + device.active = ACTIVE; + + return device; + } + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/DirectoryTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/DirectoryTest.java new file mode 100644 index 00000000..bae419cd --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/DirectoryTest.java @@ -0,0 +1,30 @@ +package org.schulcloud.mobile.data.model; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class DirectoryTest { + private static final String NAME = "NAME"; + + private Directory directory; + + @Before + public void setUp() { + directory = createNewDirectory(); + } + + @Test + public void testGetProperties() { + assertEquals(directory.name, NAME); + + } + + public static Directory createNewDirectory() { + Directory directory = new Directory(); + directory.name = NAME; + + return directory; + } +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/EventTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/EventTest.java new file mode 100644 index 00000000..f9488538 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/EventTest.java @@ -0,0 +1,62 @@ +package org.schulcloud.mobile.data.model; + +import org.junit.Before; +import org.junit.Test; +import org.schulcloud.mobile.data.model.jsonApi.Included; + +import io.realm.RealmList; + +import static org.junit.Assert.assertEquals; + +public class EventTest { + private static final String _ID = "ID"; + private static final String TYPE = "TEST"; + private static final String TITLE = "TEST_PATH"; + private static final Boolean ALLDAY = false; + private static final String START = "IMAGE"; + private static final String END = "TEST_THUMBNAIL"; + private static final String SUMMARY = "IMAGE"; + private static final String LOCATION = "TEST_THUMBNAIL"; + private static final RealmList INCLUDED = new RealmList<>(); + private static final String XSCCOURSEID = "COURSE"; + private static final String XSCCOURSETIMEID = "COURSEID"; + + private Event event; + + @Before + public void setUp() { + event = createNewEvent(); + } + + @Test + public void testGetProperties() { + assertEquals(event._id, _ID); + assertEquals(event.type, TYPE); + assertEquals(event.title, TITLE); + assertEquals(event.allDay, ALLDAY); + assertEquals(event.start, START); + assertEquals(event.end, END); + assertEquals(event.summary, SUMMARY); + assertEquals(event.location, LOCATION); + assertEquals(event.included, INCLUDED); + assertEquals(event.xScCourseId, XSCCOURSEID); + assertEquals(event.xScCourseTimeId, XSCCOURSETIMEID); + } + + public static Event createNewEvent() { + Event event = new Event(); + event._id = _ID; + event.type = TYPE; + event.title = TITLE; + event.allDay = ALLDAY; + event.start = START; + event.end = END; + event.summary = SUMMARY; + event.location = LOCATION; + event.included = INCLUDED; + event.xScCourseId = XSCCOURSEID; + event.xScCourseTimeId = XSCCOURSETIMEID; + + return event; + } +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/FileTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/FileTest.java new file mode 100644 index 00000000..824206c3 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/FileTest.java @@ -0,0 +1,45 @@ +package org.schulcloud.mobile.data.model; + +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +public class FileTest { + + private static final String KEY = "key"; + private static final String NAME = "TestFile.jpg"; + private static final String PATH = "TEST_PATH"; + private static final String SIZE = "200"; + private static final String TYPE = "IMAGE"; + private static final String THUMBNAIL = "TEST_THUMBNAIL"; + + private File file; + + @Before + public void setUp() { + file = createNewFile(); + } + + @Test + public void testGetProperties() { + assertEquals(file.key, KEY); + assertEquals(file.name, NAME); + assertEquals(file.path, PATH); + assertEquals(file.size, SIZE); + assertEquals(file.type, TYPE); + assertEquals(file.thumbnail, THUMBNAIL); + } + + public static File createNewFile() { + File file = new File(); + file.key = KEY; + file.name = NAME; + file.path = PATH; + file.size = SIZE; + file.type = TYPE; + file.thumbnail = THUMBNAIL; + + return file; + } + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/UserTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/UserTest.java new file mode 100644 index 00000000..a857e4d6 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/UserTest.java @@ -0,0 +1,101 @@ +package org.schulcloud.mobile.data.model; + +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; + +public class UserTest { + + private static final String _ID = "key"; + private static final String FIRSTNAME = "Ernst"; + private static final String LASTNAME = "Haft"; + private static final String EMAIL = "ernst@haft.bla"; + private static final String SCHOOLID = "123214123"; + private static final String DISPLAYNAME = "Ernst Haft"; + + private User user; + + @Before + public void setUp() { + user = createNewUser(); + } + + public static User createNewUser() { + User user = new User(); + user.set_id(_ID); + user.setDisplayName(DISPLAYNAME); + user.setSchoolId(SCHOOLID); + user.setLastName(LASTNAME); + user.setFirstName(FIRSTNAME); + user.setEmail(EMAIL); + + return user; + } + + @Test + public void get_id() throws Exception { + assertEquals(user.get_id(), _ID); + } + + @Test + public void set_id() throws Exception { + user.set_id(_ID); + assertNotNull(user.get_id()); + } + + @Test + public void getFirstName() throws Exception { + assertEquals(user.getFirstName(), FIRSTNAME); + } + + @Test + public void setFirstName() throws Exception { + user.setFirstName(FIRSTNAME); + assertNotNull(user.getFirstName()); + } + + @Test + public void getLastName() throws Exception { + assertEquals(user.getLastName(), LASTNAME); + } + + @Test + public void setLastName() throws Exception { + user.setLastName(LASTNAME); + assertNotNull(user.getLastName()); + } + + @Test + public void getEmail() throws Exception { + assertEquals(user.getEmail(), EMAIL); + } + + @Test + public void setEmail() throws Exception { + user.setEmail(EMAIL); + assertNotNull(user.getEmail()); + } + + @Test + public void getSchoolId() throws Exception { + assertEquals(user.getSchoolId(), SCHOOLID); + } + + @Test + public void setSchoolId() throws Exception { + user.setSchoolId(SCHOOLID); + assertNotNull(user.getSchoolId()); + } + + @Test + public void getDisplayName() throws Exception { + assertEquals(user.getDisplayName(), DISPLAYNAME); + } + + @Test + public void setDisplayName() throws Exception { + user.setDisplayName(DISPLAYNAME); + assertNotNull(user.getDisplayName()); + } + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/jsonApi/IncludedAttributesTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/jsonApi/IncludedAttributesTest.java new file mode 100644 index 00000000..90e3fc3a --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/jsonApi/IncludedAttributesTest.java @@ -0,0 +1,63 @@ +package org.schulcloud.mobile.data.model.jsonApi; + +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +public class IncludedAttributesTest { + private static final String FREQ = "FREQ"; + private static final String UNTIL = "UNTIL"; + private static final String WKST = "WKST"; + + private IncludedAttributes includedAttributes; + + @Before + public void setUp() throws Exception { + includedAttributes = newIncludedAttributes(); + } + + public static IncludedAttributes newIncludedAttributes() { + IncludedAttributes includedAttributes = new IncludedAttributes(); + includedAttributes.setFreq(FREQ); + includedAttributes.setUntil(UNTIL); + includedAttributes.setWkst(WKST); + + return includedAttributes; + } + + @Test + public void getFreq() throws Exception { + assertEquals(includedAttributes.getFreq(), FREQ); + } + + @Test + public void setFreq() throws Exception { + includedAttributes.setFreq(FREQ); + assertNotNull(includedAttributes.getFreq()); + } + + @Test + public void getUntil() throws Exception { + assertEquals(includedAttributes.getUntil(), UNTIL); + } + + @Test + public void setUntil() throws Exception { + includedAttributes.setUntil(UNTIL); + assertNotNull(includedAttributes.getUntil()); + } + + @Test + public void getWkst() throws Exception { + assertEquals(includedAttributes.getWkst(), WKST); + } + + @Test + public void setWkst() throws Exception { + includedAttributes.setWkst(WKST); + assertNotNull(includedAttributes.getWkst()); + } + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/jsonApi/IncludedTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/jsonApi/IncludedTest.java new file mode 100644 index 00000000..29a00263 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/jsonApi/IncludedTest.java @@ -0,0 +1,63 @@ +package org.schulcloud.mobile.data.model.jsonApi; + +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; +import static junit.framework.Assert.assertNotNull; + +public class IncludedTest { + private static final String TYPE = "TYPE"; + private static final String ID = "ID"; + private static final IncludedAttributes ATTRIBUTES = new IncludedAttributes(); + + private Included included; + + @Before + public void setUp() throws Exception { + included = newIncluded(); + } + + public static Included newIncluded() { + Included included = new Included(); + included.setAttributes(ATTRIBUTES); + included.setId(ID); + included.setType(TYPE); + + return included; + } + + @Test + public void getType() throws Exception { + assertEquals(included.getType(), TYPE); + } + + @Test + public void setType() throws Exception { + included.setType(TYPE); + assertNotNull(included.getType()); + } + + @Test + public void getId() throws Exception { + assertEquals(included.getId(), ID); + } + + @Test + public void setId() throws Exception { + included.setId(ID); + assertNotNull(included.getId()); + } + + @Test + public void getAttributes() throws Exception { + assertEquals(included.getAttributes(), ATTRIBUTES); + } + + @Test + public void setAttributes() throws Exception { + included.setAttributes(ATTRIBUTES); + assertNotNull(included.getAttributes()); + } + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/requestBodies/CallbackRequestTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/requestBodies/CallbackRequestTest.java new file mode 100644 index 00000000..137ad851 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/requestBodies/CallbackRequestTest.java @@ -0,0 +1,31 @@ +package org.schulcloud.mobile.data.model.requestBodies; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class CallbackRequestTest { + private static final String TYPE = "ERNST"; + private static final String NOTIFICATIONID = "1234567890"; + + private CallbackRequest callbackRequest; + + @Before + public void setUp() { + callbackRequest = createNewCallbackRequest(); + } + + @Test + public void testGetProperties() { + assertEquals(callbackRequest.notificationId, NOTIFICATIONID); + assertEquals(callbackRequest.type, TYPE); + } + + public static CallbackRequest createNewCallbackRequest() { + CallbackRequest callbackRequest = new CallbackRequest(NOTIFICATIONID, TYPE); + + return callbackRequest; + } + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/requestBodies/CredentialsTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/requestBodies/CredentialsTest.java new file mode 100644 index 00000000..cdaee2c8 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/requestBodies/CredentialsTest.java @@ -0,0 +1,32 @@ +package org.schulcloud.mobile.data.model.requestBodies; + +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class CredentialsTest { + private static final String USERNAME = "ERNST"; + private static final String PASSWORD = "1234567890"; + + private Credentials credentials; + + @Before + public void setUp() { + credentials = createNewCredentials(); + } + + @Test + public void testGetProperties() { + assertEquals(credentials.username, USERNAME); + assertEquals(credentials.password, PASSWORD); + } + + public static Credentials createNewCredentials() { + Credentials credentials = new Credentials(USERNAME, PASSWORD); + + return credentials; + } + + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/requestBodies/DeviceRequestTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/requestBodies/DeviceRequestTest.java new file mode 100644 index 00000000..0cd3dfca --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/requestBodies/DeviceRequestTest.java @@ -0,0 +1,38 @@ +package org.schulcloud.mobile.data.model.requestBodies; + +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; + +public class DeviceRequestTest { + private static final String SERVICE = "SERVICE"; + private static final String NAME = "NAME"; + private static final String OS = "MAGIC"; + private static final String DEVICE_TOKEN = "UNKNOWN"; + private static final String TYPE = "YESTERDAY"; + private static final String TOKEN = "TRUE"; + + private DeviceRequest deviceRequest; + + @Before + public void setUp() throws Exception { + deviceRequest = newDeviceRequest(); + } + + @Test + public void testForConstructor() { + assertEquals(deviceRequest.service, SERVICE); + assertEquals(deviceRequest.name, NAME); + assertEquals(deviceRequest.OS, OS); + assertEquals(deviceRequest.device_token, DEVICE_TOKEN); + assertEquals(deviceRequest.type, TYPE); + assertEquals(deviceRequest.token, TOKEN); + } + + public static DeviceRequest newDeviceRequest() { + DeviceRequest deviceRequest = new DeviceRequest(SERVICE, TYPE, NAME, TOKEN, DEVICE_TOKEN, OS); + + return deviceRequest; + } +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/responseBodies/DeviceResponseTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/responseBodies/DeviceResponseTest.java new file mode 100644 index 00000000..edc2b9e5 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/responseBodies/DeviceResponseTest.java @@ -0,0 +1,33 @@ +package org.schulcloud.mobile.data.model.responseBodies; + +import org.junit.Before; +import org.junit.Test; + +import static junit.framework.Assert.assertEquals; + +public class DeviceResponseTest { + private static final String TYPE = "LUKE"; + private static final String ID = "VADER"; + + private DeviceResponse deviceResponse; + + @Before + public void setUp() throws Exception { + deviceResponse = createDeviceResponse(); + } + + @Test + public void testGetProperties() { + assertEquals(deviceResponse.type, TYPE); + assertEquals(deviceResponse.id, ID); + } + + public static DeviceResponse createDeviceResponse() { + DeviceResponse deviceResponse = new DeviceResponse(); + deviceResponse.type = TYPE; + deviceResponse.id = ID; + + return deviceResponse; + } + +} \ No newline at end of file diff --git a/app/src/test/java/org/schulcloud/mobile/data/model/responseBodies/FilesResponseTest.java b/app/src/test/java/org/schulcloud/mobile/data/model/responseBodies/FilesResponseTest.java new file mode 100644 index 00000000..36d25e71 --- /dev/null +++ b/app/src/test/java/org/schulcloud/mobile/data/model/responseBodies/FilesResponseTest.java @@ -0,0 +1,42 @@ +package org.schulcloud.mobile.data.model.responseBodies; + + +import org.junit.Before; +import org.junit.Test; +import org.schulcloud.mobile.data.model.Directory; +import org.schulcloud.mobile.data.model.File; + +import java.util.ArrayList; +import java.util.List; + +import static junit.framework.Assert.assertEquals; + +public class FilesResponseTest { + + public List files; + public List directories; + + private static final List FILE_LIST = new ArrayList(); + private static final List DIRECTORY_LIST = new ArrayList(); + + private FilesResponse filesResponse; + + @Before + public void setUp() throws Exception { + filesResponse = createFilesResponse(); + } + + @Test + public void testGetProperties() { + assertEquals(filesResponse.directories, DIRECTORY_LIST); + assertEquals(filesResponse.files, FILE_LIST); + } + + public static FilesResponse createFilesResponse() { + FilesResponse filesResponse = new FilesResponse(); + filesResponse.files = FILE_LIST; + filesResponse.directories = DIRECTORY_LIST; + + return filesResponse; + } +} \ No newline at end of file