From a5a9b3317746373adee4218cb259ecf3cc5f80b7 Mon Sep 17 00:00:00 2001 From: Bojnourdi Date: Sun, 23 Aug 2015 17:23:59 +0200 Subject: [PATCH] Work on unit tests --- .../com/edf/gde/dao/AttributeDaoClient.java | 2 +- .../src/com/edf/gde/dao/FileDaoClient.java | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 projects/GDE-test/src/com/edf/gde/dao/FileDaoClient.java diff --git a/projects/GDE-test/src/com/edf/gde/dao/AttributeDaoClient.java b/projects/GDE-test/src/com/edf/gde/dao/AttributeDaoClient.java index 52b6591..43ca512 100644 --- a/projects/GDE-test/src/com/edf/gde/dao/AttributeDaoClient.java +++ b/projects/GDE-test/src/com/edf/gde/dao/AttributeDaoClient.java @@ -31,7 +31,7 @@ public class AttributeDaoClient extends BaseDao { getContext().setPassword("edf123"); } - public AttributeDaoClient(DaoResponseHandler daoResponseHandler, RestContext context) { + public AttributeDaoClient(RestContext context) { super(context); } diff --git a/projects/GDE-test/src/com/edf/gde/dao/FileDaoClient.java b/projects/GDE-test/src/com/edf/gde/dao/FileDaoClient.java new file mode 100644 index 0000000..f27ebd6 --- /dev/null +++ b/projects/GDE-test/src/com/edf/gde/dao/FileDaoClient.java @@ -0,0 +1,53 @@ +/* + * (C) 2015 EDF + */ +package com.edf.gde.dao; + +import com.edf.gde.transferables.CommandTO; +import com.edf.gde.transferables.FileTO; +import java.io.IOException; +import restapi.RestContext; + +/** + * + * @author Kavoos + */ +public class FileDaoClient extends BaseDao { + + public static final String ServiceName = "FileService"; + public static final int CREATEFILE = 1; + public static final int DELETEFILE = 2; + public static final int UPDATEFILE = 3; + public static final int READFILE = 4; + public static final int FINDBYNAME = 5; + public static final int CREATECHUNK = 6; + public static final int READCHUNK = 7; + + public FileDaoClient() { + getContext().setBaseResource("http://localhost:8080/GDE-war/"+ServiceName); + getContext().setUserName("admin"); + getContext().setPassword("edf123"); + } + + public FileDaoClient(RestContext context) { + super(context); + } + + public FileTO createFile(FileTO fileTO) throws IOException { + CommandTO commandTO = createCommand(CREATEFILE); + return postCommand(commandTO, fileTO, FileTO.class); + } + + public void deleteFile(long fileId) throws IOException { + CommandTO commandTO = createCommand(DELETEFILE); + commandTO.setLong("fileId", fileId); + postCommand(commandTO, null); + } + + public FileTO updateFile(FileTO fileTO) throws IOException { + CommandTO commandTO = createCommand(UPDATEFILE); + commandTO.setData(toJson(fileTO)); + return postCommand(commandTO, fileTO, FileTO.class); + } + +} -- 2.39.2