Commit 46137254 authored by spurthi.segu's avatar spurthi.segu Committed by Madan Lanka

Junit fixes and review comment fixes for Simulator.

Change-Id: I215a83ef94b8b503018cf983bf36fc14bbe66c77
Signed-off-by: default avatarspurthi.segu <spurthi.segu@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3727Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarMadan Lanka <lanka.madan@samsung.com>
parent 3bbbdecd
......@@ -75,7 +75,7 @@ typedef enum
SIMULATOR_TYPE_MISMATCH,
SIMULATOR_BAD_VALUE,
SIMULATOR_BAD_OBJECT,
/** Simulator specific error codes - START */
/** Simulator specific error codes - END */
SIMULATOR_ERROR = 255
} SimulatorResult;
......
......@@ -1384,17 +1384,7 @@ public class ResourceManager {
if (null != resourceServerN) {
try {
resourceServerN.stopAutomation(autoId);
} catch (InvalidArgsException e) {
Activator
.getDefault()
.getLogManager()
.log(Level.ERROR.ordinal(),
new Date(),
"[" + e.getClass().getSimpleName() + "]"
+ e.code().toString() + "-"
+ e.message());
return;
}catch (SimulatorException e) {
} catch (SimulatorException e) {
Activator
.getDefault()
.getLogManager()
......@@ -1533,16 +1523,6 @@ public class ResourceManager {
// Call native method
try {
resourceServer.stopAutomation(autoId);
} catch (InvalidArgsException e) {
Activator
.getDefault()
.getLogManager()
.log(Level.ERROR.ordinal(),
new Date(),
"[" + e.getClass().getSimpleName() + "]"
+ e.code().toString() + "-"
+ e.message());
return false;
} catch (SimulatorException e) {
Activator
.getDefault()
......
......@@ -603,20 +603,20 @@ Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_stopAutomation
throwSimulatorException(env, SIMULATOR_BAD_OBJECT, "No resource!");
return;
}
try
try
{
resource->stopUpdateAutomation(automationId);
}
catch (InvalidArgsException &e)
catch (SimulatorException &e)
{
throwInvalidArgsException(env, e.code(), e.what());
throwSimulatorException(env, e.code(), e.what());
}
catch (...)
{
throwSimulatorException(env, SIMULATOR_ERROR, "Unknown Exception");
}
}
SIM_LOG(ILogger::INFO, "Automation has been forcibly stopped.")
}
......
......@@ -161,7 +161,7 @@ public class SimulatorRemoteResource {
throw new InvalidArgsException(
SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
"Parameter passed in invalid");
this.get(null, queryParamsMap, onGetListener);
this.nativeGet(null, queryParamsMap, onGetListener);
}
/**
......@@ -188,11 +188,11 @@ public class SimulatorRemoteResource {
public void get(String resourceInterface,
Map<String, String> queryParamsMap, IGetListener onGetListener)
throws InvalidArgsException, NoSupportException, SimulatorException {
if (resourceInterface.isEmpty() || null == onGetListener)
if (null == resourceInterface || resourceInterface.isEmpty() || null == onGetListener)
throw new InvalidArgsException(
SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
"Parameter passed in invalid");
this.get(resourceInterface, queryParamsMap, onGetListener);
this.nativeGet(resourceInterface, queryParamsMap, onGetListener);
}
private native void nativeGet(String resourceInterface,
......@@ -228,7 +228,7 @@ public class SimulatorRemoteResource {
throw new InvalidArgsException(
SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
"Parameter passed in invalid");
this.put(null, representation, queryParamsMap, onPutListener);
this.nativePut(null, representation, queryParamsMap, onPutListener);
}
/**
......@@ -259,11 +259,12 @@ public class SimulatorRemoteResource {
SimulatorResourceModel representation,
Map<String, String> queryParamsMap, IPutListener onPutListener)
throws InvalidArgsException, NoSupportException, SimulatorException {
if (resourceInterface.isEmpty() || null == representation || null == onPutListener)
if (null == resourceInterface || resourceInterface.isEmpty() ||
null == representation || null == onPutListener)
throw new InvalidArgsException(
SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
"Parameter passed in invalid");
this.put(resourceInterface, representation, queryParamsMap, onPutListener);
this.nativePut(resourceInterface, representation, queryParamsMap, onPutListener);
}
private native void nativePut(String resourceInterface,
......@@ -300,7 +301,7 @@ public class SimulatorRemoteResource {
throw new InvalidArgsException(
SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
"Parameter passed in invalid");
this.post(null, representation, queryParamsMap, onPostListener);
this.nativePost(null, representation, queryParamsMap, onPostListener);
}
/**
......@@ -331,11 +332,12 @@ public class SimulatorRemoteResource {
SimulatorResourceModel representation,
Map<String, String> queryParamsMap, IPostListener onPostListener)
throws InvalidArgsException, NoSupportException, SimulatorException {
if (resourceInterface.isEmpty() || null == representation || null == onPostListener)
if (null == resourceInterface || resourceInterface.isEmpty() ||
null == representation || null == onPostListener)
throw new InvalidArgsException(
SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
"Parameter passed in invalid");
this.post(resourceInterface, representation, queryParamsMap, onPostListener);
this.nativePost(resourceInterface, representation, queryParamsMap, onPostListener);
}
private native void nativePost(String resourceInterface,
......
......@@ -389,7 +389,7 @@ public class SimulatorResourceServer {
* This exception will be thrown for other errors.
*/
public native void stopAutomation(int automationId)
throws InvalidArgsException, SimulatorException;
throws SimulatorException;
/**
* API to remove an attribute from the simulated resource.
......
......@@ -114,8 +114,8 @@ void UpdateAutomationMngr::stop(int id)
return;
}
//Throw InvalidArgsException
throw InvalidArgsException(SIMULATOR_INVALID_PARAM, "Invalid Automation Id!");
//Throw SimulatorException
throw SimulatorException(SIMULATOR_ERROR, "No automation is currently in progress for the given automation Id!");
}
void UpdateAutomationMngr::stopAll()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment