#MethodSource with 3 method sources - junit

I have a scenario where my test method requires the source from 3 different methods.
#ParameterizedTest
#MethodSource({"source1","source2","source3"})
testMyMethod(param1 , param2 , param3)
{
//TO DO
do something using param1
do something using param2
do something using param3
}
All the params (1,2,3) are a custom java object, and source 1 returns param1 , source2 returns param2 , source 3 returns param3.
Can anyone please give me the idea of how to implement this?

Related

r2dbc:Calling Stored Proc in mysql with in and out parameters

Does r2dbc currently supports calling Stored proc in my sql with in/out parameters ?
I am trying to call Stored Proc using databaseClient which returns a String.But I am getting the below exception.Do I have to add anything to call SP from r2dbc.My stored procedure looks like this.How to call SP using database-client
CREATE PROCEDURE usp_get_data(in someId varchar(255),
in someName varchar(255),
out email varchar(255))
BEGIN
SELECT email FROM products where id=:someId and name=:someName LIMIT 1;
END //
Below is my code.
String STORED_PROC = "call usp_get_data(:someId,:someName)"
def result = databaseClient.execute(STORED_PROC)
.bindNull("someId","someId")
.bindNull("someName", "someName")
.as(String.class)
.fetch().one()
Incorrect number of arguments for PROCEDURE usp_get_data expected 3, got 2))
Forgot to add #out in the call stored procedure statement.
modifying my execution below worked.
String STORED_PROC = "call usp_get_data(:someId,:someName,#email);
Select #email"

How to get the PeekPokeTester expect function to print signal values in hex?

By default when I call the expect() function in the tester the values come up as decimals. Although in the provided example here:
https://github.com/freechipsproject/chisel-testers/wiki/Using-the-PeekPokeTester
the outputs comes out as hex. How can you select this?
example:
[info] [0.026] EXPECT AT 5 io_key_column got 979262996 expected 4293125357 FAIL
Try using the Driver.execute to run your test. It allows you to set a bunch of options by passing in an array of strings.
In this case try
val args = Array("--display-base", "16")
iotesters.Driver.execute(args, () => new RealGCD2) { c =>
new GCDPeekPokeTester(c)
} should be (true)

turn c# code into mysql function

I have the following code in C# that I would like to turn into a MySQL snippet instead?
foreach (DataRow row in dtBills.Rows)
{
classes.UtilityBill ub = new classes.UtilityBill(row);
if (ub.ApprovedBy > 0)
{
if (ub.RemainingBalance() > 0) { totalOutstanding += ub.RemainingBalance(); numberOfUnpaidBills++; }
if (ub.RemainingBalance() > 0 && ub.IsOverDue()) { numberOfOverdueBills++; }
}
else
{
if (ub.ApprovedBy == 0)
{
awaitingApproval++;
}
else
{
rejectedBills++;
}
}
}
ub.RemainingBlaance() basically checks two fields in the table and subtracts, amount_due - amount_paid
What I'm looking to have returned is a single row that looks something like:
totalOutstanding, numberOfUnpaidBills, numberOfOverdueBills, awaitingApproval, rejectedBills
Original table:
I know that this might come across like a lazy question, but I have never dealt with coding in mysql, just simple queries, and I have no idea on how to start. A push in the right direction would suffice, not a complete solution.
Thanks!
To query mysql you can use the mysql.data nuget package. You can look up their documentation. I created a nuget to simplify code from any c# framework to mysql as well. If you don't mind third party nugets, you can try it out. It is called mysql.simple. From what I understand from what the code is trying to do, here is a small code for pulling data:
using (Database db = ConnectionString) // initializes connection
{
// you can omit the below select function if you would like to select all
using (var Row = db.Select("unit_cost, start_reading")
From("tblName").Query()
while(Row.Read()){ // gets each row
ub.unit_cost = Row["unit_cost"];
ub.start_reading= Row["start_reading"];
.
.
.
}
}
The db object above has select, update and insert functions with all variations including insert statements with selects. However if you would like to use raw sql queries, you can directly use db.Query("sql query here"). You can see more documentations here http://mysqlsimple.azurewebsites.net/docs
Here is a sample mySql stored procedure I had with me:
DELIMITER //
DROP PROCEDURE IF EXISTS proc_IF;
CREATE PROCEDURE proc_IF (IN param1 INT)
BEGIN
DECLARE variable1 INT;
SET variable1 = param1 + 1;
IF variable1 = 0 THEN
SELECT variable1;
END IF;
IF param1 = 0 THEN
SELECT 'Parameter value = 0' ;
ELSE
SELECT 'Parameter value <> 0' ;
END IF;
END //
This example contains parameters, variables and if statement examples.
You can call this in c# something like this:
db.QueryValue("CALL proc_IF (#0)", myVal);

How to get Postgres function name as well as function specific name from pg_catalog.pg_proc?

Since Postgres supports function overloading, getting function name as well as function specific name(System generated without duplicates) is more meaning full.
Assume i have 2 functions in the name as Func1 which are overloaded as shown below,
CREATE FUNCTION "Schema"."Func1"(IN param1 INTEGER,
IN Param2 CHAR)
RETURNS INTEGER
AS $BODY$
begin
return param1+1;
end $BODY$
LANGUAGE PLPGSQL;#
CREATE FUNCTION "Schema"."Func1"(IN param1 INTEGER)
RETURNS INTEGER
AS $BODY$
begin
return param1+1;
end $BODY$
LANGUAGE PLPGSQL;#
How do i load the functions as well as input parameters correctly from pg_catalog.pg_proc.
With the help of information_schema.routines, there is a way to load function 1)specific_name 2) routine_name
But many other attributes are missing in information_schema.routines like 1) isWindow function 2) isStrict function 3) isProRetSet function
So is there some other means to get the function specific_name from pg_catalog.....
A general method is to use psql -E or set ECHO_HIDDEN inside psql and look at the queries it generates for backslash commands.
For instance, \df "Func1" produces this with PostgreSQL 9.1:
SELECT n.nspname as "Schema",
p.proname as "Name",
pg_catalog.pg_get_function_result(p.oid) as "Result data type",
pg_catalog.pg_get_function_arguments(p.oid) as "Argument data types",
CASE
WHEN p.proisagg THEN 'agg'
WHEN p.proiswindow THEN 'window'
WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger'
ELSE 'normal'
END as "Type"
FROM pg_catalog.pg_proc p
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE p.proname ~ '^(Func1)$'
AND pg_catalog.pg_function_is_visible(p.oid)
ORDER BY 1, 2, 4;
which gives you directions about how to get the different function signatures associated to the name "Func1"
The same with \df+ would lead to the other attributes, like volatility.

Passing values for multi-value parameter in SSRS query string

I have two reports built using SSRS 2005. The first report is set to navigate to the second when a specific field is clicked. I am using an expression similar to the following in the "Jump to URL" property of the textbox:
="javascript:void(window.open('http://server/reportserver?%2fFolder%2fMyReport&rs:Command=Render&Date=" & Fields!Date.Value & "&MachineId=" & Fields!Machine.Value & "'))"
There is a multi-value parameter on the second report. I need to pass multiple values for this parameter in the URL query string when calling this report. Is there a way to pass multiple values for a parameter in the query string of a report? Or can you pass a parameter that will cause the Select All value to be selected?
Thanks.
Just add additional query string parameters.
For example, to pass the parameters
Date: 2009-06-01
MachineID: Machine1, Machine2, Machine3, Machine4
to a report named Folder\MyReport on a server named server, you would use the URL:
http://server/reportserver?%2fFolder%2fMyReport&rs:Command=Render&Date=2009-06-01&MachineId=Machine1&MachineId=Machine2&MachineId=Machine3&MachineId=Machine4
Use join(Parameters!<name>.Value,"&<param_name>=") in the url for multivalued parameters.
If you are passing these parameters into a dataset you need to do a join(Parameters!<param name>.Value) when you pass the parameter in and then use a split function in SQL. This one works well:
ALTER FUNCTION [dbo].[fnSplitParam]
(#RepParam nvarchar(4000), #Delim char(1)= ',')
RETURNS #Values TABLE (Param nvarchar(4000))AS
BEGIN
DECLARE #chrind INT
DECLARE #Piece nvarchar(100)
SELECT #chrind = 1
WHILE #chrind > 0
BEGIN
SELECT #chrind = CHARINDEX(#Delim,#RepParam)
IF #chrind > 0
SELECT #Piece = LEFT(#RepParam,#chrind - 1)
ELSE
SELECT #Piece = #RepParam
INSERT #Values(Param) VALUES(CAST(#Piece AS VARCHAR))
SELECT #RepParam = RIGHT(#RepParam,LEN(#RepParam) - #chrind)
IF LEN(#RepParam) = 0 BREAK
END
RETURN
END
I recommend using the single valued method if the end user does not have to select the parameters directly since it saves you 2 characters per parameter in the url.
I've been trying to do a similar thing to OP, and found putting this &rp:mySelectAllParameter=<ALL> in the url works to select all