diff --git a/src/test/java/hibernateTest/models/Groups.java b/src/test/java/hibernateTest/models/Groups.java new file mode 100644 index 0000000..7d08be1 --- /dev/null +++ b/src/test/java/hibernateTest/models/Groups.java @@ -0,0 +1,114 @@ +package hibernateTest.models; + +import com.example.cosmos_serversb.entities.Group; +import com.example.cosmos_serversb.entities.Request; +import com.example.cosmos_serversb.models.DeleteResult; + +import javax.inject.Singleton; +import java.util.HashMap; + + +@Singleton +public class Groups { + private static Groups theInstance = null; + + private Groups(){ + + } + + public static Groups getInstance(){ + if(theInstance == null){ + theInstance = new Groups(); + } + return theInstance; + } + + public static HashMap getGroupsListByUid(String uId){ + return createTestHashMap(); + } + + public static Group createGroup(String name, String uId){ + //先にGidとuriの発行を行う + Group testGroup = new Group("123456789", "http://test.com", name, uId); + + return testGroup; + } + + public static Group getGroupByGid(String gId){ + Group editGroup; + /* + for (int i = 0; i < groups.size(); i++) { + editGroup = groups.get(i); + if (editGroup.getgId().equals(gId)) { + return editGroup; + } + } + */ + return null; + } + + public static DeleteResult deleteGroup(String gId){ + Group editGroup = Groups.getInstance().getGroupByGid(gId); + if(editGroup == null){ + return DeleteResult.FAILURE; + } + //以下に削除処理を行う。 + return DeleteResult.SUCCESS; + } + + public static HashMap getMembersListByGid(String gId){ + return createTestHashMap(); + } + + public static HashMap addMember(String gId, String uId){ + return createTestHashMap(); + } + + public static HashMap deleteMember(String gId, String uId){ + return createTestHashMap(); + } + + public static HashMap getRequestsListByGid(String gId){ + return createTestHashMap(); + } + + public static Request addRequests(String gId, String uId, String product, String deadline, int location){ + //テスト用 + Request testRequest = new Request("123456789", "http://test.com", "1999/01/01/15:00:00", + uId, product, "1999/01/01/15:00:00", 999); + return testRequest; + } + + public static Request getRequestDetailByGidAndRid(String gId, String rId){ + return null; + } + + public static Request updateRequest(String gId, String rId, String uId, String product, String deadline, int location, boolean done){ + + //テスト用 + Request testRequest = new Request("123456789", "http://test.com", "1999/01/01/15:00:00", + uId, product, "1999/01/01/15:00:00", 999); + + return testRequest; + } + + public static DeleteResult deleteRequest(String gId, String rId){ + return DeleteResult.SUCCESS; + } + + //テスト用にHashMapの作成 + public static HashMap createTestHashMap(){ + HashMap testMap = new HashMap<>(); + testMap.put("123456780", "http://test0.com"); + testMap.put("123456781", "http://test1.com"); + testMap.put("123456782", "http://test2.com"); + /* + //Key, valueの取り出し方例(拡張for文) + for (String key : TestMap.keySet()) { + System.out.println(key + " " + TestMap.get(key)); + } + */ + return testMap; + } + +}