use of com.hp.oo.sdk.content.plugin.GlobalSessionObject in project cs-actions by CloudSlang.
the class SQLQueryTest method executeSuccess.
@Test
public void executeSuccess() throws Exception {
final String aKey = "akey";
final GlobalSessionObject<Map<String, Object>> globalSessionObject = new GlobalSessionObject<>();
final Map<String, Object> stringMap = new HashMap<>();
stringMap.put(aKey, aKey);
globalSessionObject.setResource(new SQLSessionResource(stringMap));
mockStatic(SQLInputsUtils.class);
when(SQLInputsUtils.getSqlKey(any(SQLInputs.class))).thenReturn(aKey);
when(SQLInputsUtils.getOrDefaultGlobalSessionObj(any(GlobalSessionObject.class))).thenReturn(globalSessionObject);
final Map<String, String> resultMap = sqlQuery.execute("1", MSSQL_DB_TYPE, "username", "Password", "someInstance", "123", "db", AUTH_SQL, EMPTY, EMPTY, "something", "true", EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, TYPE_FORWARD_ONLY, CONCUR_READ_ONLY, FALSE, globalSessionObject);
verifyStatic();
assertThat(resultMap.get(RETURN_CODE), is(NO_MORE));
assertThat(resultMap.get(RETURN_RESULT), is(DBResponseNames.NO_MORE));
}
use of com.hp.oo.sdk.content.plugin.GlobalSessionObject in project cs-actions by CloudSlang.
the class ConnectionManagerBuilderTest method buildConnectionManagerNewConnectionManager.
@Test
public void buildConnectionManagerNewConnectionManager() {
PoolingHttpClientConnectionManager connectionManager = new ConnectionManagerBuilder().setConnectionManagerMapKey("key1", "key2").setSslsf(sslConnectionSocketFactoryMock).setConnectionPoolHolder(new GlobalSessionObject()).buildConnectionManager();
assertNotNull(connectionManager);
}
use of com.hp.oo.sdk.content.plugin.GlobalSessionObject in project cs-actions by CloudSlang.
the class CounterProcessor method init.
public void init(String to, String from, String by, boolean reset, GlobalSessionObject<Map<String, Object>> session) throws CounterImplException {
/*
* If the session resource is not ini
*/
if (session.get() == null) {
session.setResource(new CounterSessionResource(new HashMap<String, Object>()));
}
Map<String, Object> sessionMap = session.get();
try {
start = Long.parseLong(from.trim());
end = Long.parseLong(to.trim());
if (by == null || by.length() == 0)
increment = 1;
else
try {
increment = Integer.parseInt(by);
} catch (Exception e) {
increment = 1;
}
} catch (Exception e) {
throw new CounterImplException("Start or end is not a long integer, or by is not an integer.\nfrom: " + from + "\nto: " + to + "\nby:" + by);
}
try {
index = (Integer) sessionMap.get(INDEX);
} catch (Exception e) {
index = 0;
}
if (index == 0 && initialized(session)) {
sessionMap.put(INDEX, 0);
}
// ok, now push data into context
if (!initialized(session)) {
sessionMap.put(INDEX, 0);
}
// pull data from context
this.index = (Integer) sessionMap.get(INDEX);
}
use of com.hp.oo.sdk.content.plugin.GlobalSessionObject in project cs-actions by CloudSlang.
the class IteratorProcessor method init.
public void init(String list, String delim, GlobalSessionObject<Map<String, Object>> session) throws IteratorProcessorException {
if (session.get() == null) {
session.setResource(new IteratorSessionResource(new HashMap<String, Object>()));
}
Map<String, Object> sessionMap = session.get();
if (list != null && delim != null) {
if (delim.length() == 0) {
throw new IteratorProcessorException("delimiter has null or 0 length");
}
// Get array list value
try {
splitList = (String[]) sessionMap.get(TEXT_ARRAYLIST);
} catch (Exception e) {
splitList = new String[0];
}
// Get String list value
String stringList;
try {
stringList = (String) sessionMap.get(TEXT_STRINGLIST);
} catch (Exception e) {
stringList = "";
}
// Get index value
try {
index = (Integer) sessionMap.get(TEXT_INDEX);
} catch (Exception e) {
index = 0;
}
if (splitList == null) {
splitList = new String[0];
}
if (stringList == null) {
stringList = "";
}
if (index == 0 && initialized(session)) {
if (list.indexOf(stringList) != 0) {
stringList = "";
splitList = new String[0];
}
sessionMap.put(TEXT_ARRAYLIST, splitList);
sessionMap.put(TEXT_INDEX, 0);
}
if (!initialized(session) || !stringList.equals(list)) {
String lastIn = list;
int index = list.indexOf(stringList);
if (index == 0) {
if (list.length() == 0) {
throw new IteratorProcessorException("list has null or 0 length");
}
splitList = ListProcessor.toArray(list, delim);
} else {
if (initialized(session) && list.startsWith(delim)) {
list = list.substring(1, list.length());
}
String[] listarray = ListProcessor.toArray(list, delim);
splitList = combine(this.splitList, listarray);
}
if (list == "" && splitList.length == 0) {
throw new IteratorProcessorException("list has null or zero length");
}
// ok, now push data into context
if (!initialized(session)) {
sessionMap.put(TEXT_INDEX, 0);
}
sessionMap.put(TEXT_ARRAYLIST, splitList);
sessionMap.put(TEXT_STRINGLIST, lastIn);
}
}
// pull data from context
splitList = (String[]) sessionMap.get(TEXT_ARRAYLIST);
index = (Integer) sessionMap.get(TEXT_INDEX);
}
use of com.hp.oo.sdk.content.plugin.GlobalSessionObject in project cs-actions by CloudSlang.
the class SFTPTest method testSaveToCache.
@Test
public void testSaveToCache() {
SFTPService sftpService = new SFTPService();
String sessionId = "sessionId";
boolean savedToCache = sftpService.saveToCache(globalSessionObjectMock, sftpCopierMock, sessionId);
assertFalse(savedToCache);
when(sftpCopierMock.saveToCache(globalSessionObjectMock, sessionId)).thenReturn(true);
savedToCache = sftpService.saveToCache(globalSessionObjectMock, sftpCopierMock, sessionId);
assertTrue(savedToCache);
final GlobalSessionObject<Map<String, SFTPConnection>> sessionParam = new GlobalSessionObject<>();
when(sftpCopierMock.saveToCache(sessionParam, sessionId)).thenReturn(true);
savedToCache = sftpService.saveToCache(sessionParam, sftpCopierMock, sessionId);
assertEquals(sessionParam.getName(), "sshSessions:default-id");
assertTrue(savedToCache);
}
Aggregations