Jelajahi Sumber

- use lombok
- remove m prefix
- correct assert output
- add licence

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>

tobiasKaminsky 6 tahun lalu
induk
melakukan
a97eb3b45b

+ 10 - 31
src/main/java/com/owncloud/android/utils/OwnCloudSession.java

@@ -1,4 +1,4 @@
-/**
+/*
  * ownCloud Android client application
  *
  * @author Bartek Przybylski
@@ -19,37 +19,16 @@
  */
 package com.owncloud.android.utils;
 
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
 /**
  * Represents a session to an ownCloud instance
  */
-public class OwnCloudSession {
-    private String mSessionName;
-    private String mSessionUrl;
-    private int mEntryId;
-
-    OwnCloudSession(String name, String url, int entryId) {
-        mSessionName = name;
-        mSessionUrl = url;
-        mEntryId = entryId;
-    }
-
-    public void setName(String name) {
-        mSessionName = name;
-    }
-
-    public String getName() {
-        return mSessionName;
-    }
-
-    public void setUrl(String url) {
-        mSessionUrl = url;
-    }
-
-    public String getUrl() {
-        return mSessionUrl;
-    }
-
-    int getEntryId() {
-        return mEntryId;
-    }
+@AllArgsConstructor
+class OwnCloudSession {
+    @Getter @Setter private String sessionName;
+    @Getter @Setter private String sessionUrl;
+    @Getter private int entryId;
 }

+ 32 - 16
src/test/java/com/owncloud/android/utils/OwnCloudSessionTest.java

@@ -1,9 +1,30 @@
+/*
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2019 Tobias Kaminsky
+ * Copyright (C) 2019 Edvard Holst
+ * Copyright (C) 2019 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
 package com.owncloud.android.utils;
 
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 public class OwnCloudSessionTest {
 
@@ -11,45 +32,40 @@ public class OwnCloudSessionTest {
     private final String SESSION_URL = "https://test.cloud.local";
     private final int SESSION_ID = 1;
 
-    private OwnCloudSession ownCloudSession = new OwnCloudSession(SESSION_NAME, SESSION_URL,SESSION_ID);
+    private OwnCloudSession ownCloudSession = new OwnCloudSession(SESSION_NAME, SESSION_URL, SESSION_ID);
 
     @Before
     public void setUp() {
-        ownCloudSession.setName(SESSION_NAME);
-        ownCloudSession.setUrl(SESSION_URL);
+        ownCloudSession.setSessionName(SESSION_NAME);
+        ownCloudSession.setSessionUrl(SESSION_URL);
     }
 
     @Test
     public void setName_assertCorrectNameUpdated() {
         String newName = "newTestSession";
-        ownCloudSession.setName(newName);
-        assertEquals("OwnCloud session name updated",
-                     newName, ownCloudSession.getName());
+        ownCloudSession.setSessionName(newName);
+        assertEquals("OwnCloud session name not updated", newName, ownCloudSession.getSessionName());
     }
 
     @Test
     public void getName_assertCorrectNamedRetrieved() {
-        assertEquals("OwnCloudSession name correct",
-                     SESSION_NAME, ownCloudSession.getName());
+        assertEquals("OwnCloudSession name not correct", SESSION_NAME, ownCloudSession.getSessionName());
     }
 
     @Test
     public void setUrl_assertCorrectUrlUpdated() {
         String newUrl = "https://new.cloud.local";
-        ownCloudSession.setUrl(newUrl);
-        assertEquals("OwnCloud session URL updated",
-                     newUrl, ownCloudSession.getUrl());
+        ownCloudSession.setSessionUrl(newUrl);
+        assertEquals("OwnCloud session URL not updated", newUrl, ownCloudSession.getSessionUrl());
     }
 
     @Test
     public void getUrl_assertCorrectUrlRetrieved() {
-        assertEquals("OwnCloudSession URL correct.",
-                     SESSION_URL, ownCloudSession.getUrl());
+        assertEquals("OwnCloudSession URL not correct", SESSION_URL, ownCloudSession.getSessionUrl());
     }
 
     @Test
     public void getEntryId_assertCorrectIdRetrieved() {
-        assertEquals("OwnCloudSession ID is correct",
-                     SESSION_ID, ownCloudSession.getEntryId());
+        assertEquals("OwnCloudSession ID is incorrect", SESSION_ID, ownCloudSession.getEntryId());
     }
 }