use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.
the class RepositoryImportResourceIT method setUp.
@Before
public void setUp() throws ObjectFactoryException {
PentahoSystem.init();
ITenant tenat = mock(ITenant.class);
resolver = mock(ITenantedPrincipleNameResolver.class);
doReturn(tenat).when(resolver).getTenant(anyString());
doReturn(REAL_USER).when(resolver).getPrincipleName(anyString());
policy = mock(IAuthorizationPolicy.class);
pentahoObjectFactory = mock(IPentahoObjectFactory.class);
when(pentahoObjectFactory.objectDefined(anyString())).thenReturn(true);
when(pentahoObjectFactory.get(this.anyClass(), anyString(), any(IPentahoSession.class))).thenAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
if (invocation.getArguments()[0].equals(IAuthorizationPolicy.class)) {
return policy;
}
if (invocation.getArguments()[0].equals(ITenantedPrincipleNameResolver.class)) {
return resolver;
}
return null;
}
});
PentahoSystem.registerObjectFactory(pentahoObjectFactory);
IPentahoSession session = mock(IPentahoSession.class);
doReturn("sampleSession").when(session).getName();
PentahoSessionHolder.setSession(session);
}
use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.
the class PentahoConnectionFactoryTest method testGetConnection.
@Test
public void testGetConnection() {
// Test constructor.
PentahoConnectionFactory factory = new PentahoConnectionFactory();
assertNotNull(factory);
String dsType = "connection-test";
IPentahoSession session = mock(IPentahoSession.class);
ILogger logger = mock(ILogger.class);
IPentahoConnection connection = PentahoConnectionFactory.getConnection(dsType, session, logger);
assertNull(connection);
String connectStr = "connect-str";
connection = PentahoConnectionFactory.getConnection(dsType, connectStr, session, logger);
assertNull(connection);
String driver = "ds-driver";
String location = "location";
String userName = "username";
String password = "password";
connection = PentahoConnectionFactory.getConnection(dsType, driver, location, userName, password, session, logger);
assertNull(connection);
connection = PentahoConnectionFactory.getConnection(dsType, null, null, null, null, session, logger);
assertNull(connection);
}
use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.
the class MetadataPublisherTest method test.
@Test
public void test() {
MetadataPublisher publisher = new MetadataPublisher();
assertNotNull(publisher.getLogger());
assertNotNull(publisher.getName());
assertNotNull(publisher.getDescription());
IPentahoSession session = mock(IPentahoSession.class);
assertNotEquals("", publisher.publish(session));
}
use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.
the class RuntimeContextTest method before.
@Before
public void before() {
mockedRuntimeRepository = mock(IRuntimeRepository.class);
mockedSolutionEngine = mock(ISolutionEngine.class);
mockedPentahoSystem = new MockUp<PentahoSystem>() {
@Mock
public <T> T get(Class<T> type, IPentahoSession session) {
if (type == IRuntimeRepository.class) {
return (T) mockedRuntimeRepository;
} else if (type == ISolutionEngine.class) {
return (T) mockedSolutionEngine;
}
throw new IllegalStateException("Unsupported type: " + type.getSimpleName());
}
@Mock
public void setApplicationContext(final IApplicationContext applicationContext) {
}
@Mock
public IApplicationContext getApplicationContext() {
final String solutionPath = ".";
final String applicationPath = "";
return new StandaloneApplicationContext(solutionPath, applicationPath);
}
};
runtimeCtx = new RuntimeContext("id", mockedSolutionEngine, "solutionName", makeRuntimeData(session), session, null, "processId", urlFactory, makeParameterProviders(session), new ArrayList<String>(), null);
}
use of org.pentaho.platform.api.engine.IPentahoSession in project pentaho-platform by pentaho.
the class BaseTest method run.
public IRuntimeContext run(String actionPath, IParameterProvider parameterProvider, String testName, String fileExtension) {
assertTrue(initOk);
OutputStream outputStream = null;
if (testName != null && fileExtension != null) {
outputStream = getOutputStream(testName, fileExtension);
}
IOutputHandler outputHandler = null;
if (outputStream != null) {
outputHandler = getOutputHandler(outputStream);
} else {
outputHandler = getOutputHandler((OutputStream) null);
}
String instanceId = null;
StandaloneSession initialSession = // $NON-NLS-1$
new StandaloneSession(Messages.getInstance().getString("BaseTest.DEBUG_JUNIT_SESSION"));
IPentahoSession session = sessionStartup(initialSession);
if (outputHandler != null) {
outputHandler.setSession(session);
}
return run(actionPath, instanceId, false, parameterProvider, outputHandler, session);
}
Aggregations