I am new to Cucumber. I have a requirement to use variables instead of actual values in a feature file example. Actual values are to be populated in a separate property file.
Sample feature file:
#tag
Feature: Add an element to stack
The user pushes an element. It gets added to stack
#tag1
Scenario: Push element to empty stack
Given Stack is empty
When User pushes an element
Then stack should have only one element
#tag2
Scenario Outline: Push element to stack
Given Stack has {initial} elements
When User adds {new} element
Then Length of stack increases to {new_size}
| initial | new | new_size |
| 1 | 2 | 2|
| 5 | 9 | 6|
| 0 | 3 | 1|
The output example should be like:
| initial | new | new_size |
| {val1_1} |{val1_2} | {val1_3}|
| {val2_1} |{val2_2} | {val2_3}|
I have used "{}" instead of "<>" as am not able to print elements inside <> in pre-formatted code
Use scenario outlines with examples. Its will solve you data input based queries. For example,
#tag2
Scenario Outline: Push element to stack
Given Stack has <initial> elements
When User adds <new> element
Then Length of stack increases to <new_size>
Examples:
| initial | new | new_size |
| 1 | 2 | 2 |
| 5 | 9 | 6 |
| 0 | 3 | 1 |
And your step definition would be like this,
Given("^Stack has (.*) elements$", (String initial) -> {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
});
Similarly do for the other query parameters like (name, new_size).
Related
i' have created label schema using graph.OpenManagement() as described in https://docs.janusgraph.org/basics/schema/#schema-constraints
mgmt = graph.openManagement()
person = mgmt.makeVertexLabel('person').make()
name = mgmt.makePropertyKey('name').dataType(String.class).cardinality(Cardinality.SET).make()
birthDate = mgmt.makePropertyKey('birthDate').dataType(Long.class).cardinality(Cardinality.SINGLE).make()
mgmt.addProperties(person, name, birthDate)
mgmt.commit()
How can I get the person label schema. What is the gremlin query to get the properties list along with the datatype and cardinality info for a label.
Im using the following query to get the properties list with the data type, but there is no map for property to the label
gremlin> mgmt.printPropertyKeys()
==>------------------------------------------------------------------------------------------------
Property Key Name | Cardinality | Data Type |
---------------------------------------------------------------------------------------------------
name2 | SINGLE | class java.lang.String |
age2 | SINGLE | class java.lang.Integer |
name3 | SET | class java.lang.String |
birthDate3 | SINGLE | class java.lang.Long |
name4 | SET | class java.lang.String |
birthDate4 | SINGLE | class java.lang.Long |
name6 | SINGLE | class java.lang.String |
age6 | SINGLE | class java.lang.Integer |
name5 | SINGLE | class java.lang.String |
age5 | SINGLE | class java.lang.Integer |
mean_radius | SINGLE | class java.lang.Integer |
distance_in_kms | SINGLE | class java.lang.Integer |
new_field | SINGLE | class java.lang.String |
radius_in_kms | SINGLE | class java.lang.Integer |
name | SINGLE | class java.lang.String |
---------------------------------------------------------------------------------------------------
Getting vertex labels and their basic information:
mgmt.getVertexLabels().forEach(vertexLabel -> {
System.out.println("Vertex label: "+vertexLabel.name()+" isPartitioned: "+vertexLabel.isPartitioned()+" isStatic: "+vertexLabel.isStatic());
});
Getting edge labels and their basic information:
mgmt.getRelationTypes(EdgeLabel.class).forEach(edgeLabel ->{
System.out.println("Edge label: "+edgeLabel.name()+" Multiplicity: "+edgeLabel.multiplicity().name()+" isUnidirected:"+edgeLabel.isUnidirected());
});
Getting properties and their basic information:
mgmt.getRelationTypes(PropertyKey.class).forEach(propertyKey -> {
System.out.println("Property key: "+propertyKey.name()+" Cardinality: "+propertyKey.cardinality().name()+" Datatype: "+propertyKey.dataType().getName());
});
Now, when you got a specific Vertex label or a specific Edge label (as shown above), you can ask for the schema constraints information as shown below. Same methods are available for both VertexLabel and EdgeLabel.
Getting vertex label properties:
VertexLabel vertexLabel = mgmt.getVertexLabel("myVertexLabel");
vertexLabel.mappedProperties().forEach(propertyKey -> {
// get information about `propertyKey` as shown above in `Getting properties and their basic information` section
});
Getting vertex label connections:
VertexLabel vertexLabel = mgmt.getVertexLabel("myVertexLabel");
vertexLabel.mappedConnections().forEach(connection -> {
// connection.getEdgeLabel() - return the label of the edge. You can use it to access the edge itself if needed like:
EdgeLabel edgeLabel = mgmt.getEdgeLabel(connection.getEdgeLabel());
// You can access JanusGraphEdge via:
JanusGraphEdge janusGraphEdge = connection.getConnectionEdge();
// Having JanusGraphEdge you can access EdgeLabel directly via:
edgeLabel = janusGraphEdge.edgeLabel();
// You can also access incoming or outgoing vertices of this connection via: connection.getIncomingVertexLabel() or connection.getOutgoingVertexLabel()
});
I have a very simple LibreOffice Calc spreadsheet with column headers and columns (cell can be multiline), someting like:
| id | Prio | Domain | Comment | ... |
|----|------|--------|----------------|-----|
| 1 | A | Foo | Something | |
|----|------|--------|----------------|-----|
| 2 | A | Bar | Something else | |
| | | | Possibly on | |
| | | | multiple lines | |
|----|------|--------|----------------|-----|
| 1 | C | Baz | Something else | |
I would like to obtain, in a (semi) automated way a plain text file containing something like:
id: 1
Prio: A
Domain: Foo
Comment: Something
...
id: 2
Prio: A
Domain: Bar
Comment: Something else
Possibly on
multiple lines
...
id: 3
Prio: C
Domain: Baz
Comment: Something else
...
Is this possible somehow?
I am aware of LO macro capabilities (e.g.: this ), so the trivial answer is probably "yes", but I never used them so I would need some guidance (I don't even know how to use such a thing).
There are a lot of different ways this could be done. One idea is to go to File -> Save As and save as type CSV. In the filter settings, check Quote all text cells to make it easier to handle newlines.
Then write a script that uses the python csv module, for example:
import csv
with open('Untitled 1.csv') as csvfile:
spamreader = csv.reader(csvfile, dialect='excel',)
for row in spamreader:
print("row: ", end="")
print(', '.join(row))
To avoid the Save As step, you could write a macro instead. It might be easier to write it in python rather than Basic, because file handling and string manipulation can be difficult in Basic.
I am having trouble getting my divs to behave the way I would like them to. Below is a mock-up of my page. The page looks great, until I make my window smaller. At that point, sub-div B will move underneath sub-div A, which is what I do not want.
How do I go about keeping sub-div A and sub-div B in line with each other even when the window size is reduced?
+--------------------------------------------------------------+
| div (container) |
| +----------------------------------------------------------+ |
| | div | |
| +----------------------------------------------------------+ |
| |
| +----------------------------------------------------------+ |
| | super div | |
| | +------------------------+ +------------------------+ | |
| | | sub-div A - float left | | sub div-B - float left | | |
| | +------------------------+ +------------------------+ | |
| +----------------------------------------------------------+ |
| |
| +----------------------------------------------------------+ |
| | div - clear both | |
| +----------------------------------------------------------+ |
| |
| +----------------------------------------------------------+ |
| | div - clear both | |
| +----------------------------------------------------------+ |
| |
+--------------------------------------------------------------+
You used float for the sub-divs and by definition that will make them wrap under each other when they cannot fit on the screen. To make sure they stay on the same line, remove the float and make them both display: inline-block and then on the super div add the style white-space: nowrap;.
I have an Entity which in turn refers to same table which is its parent. Below is the table which describes it more better.
| ID | Source_ID |
+----+----------+
| 1 | null |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
| 5 | 4 |
Now, when I am at ID = 5, I need to fetch its ultimate parent, which is ID = 1.
I tried writing a function which is as below:
<entity> ultimateparententity;
internal <entity> FetchParentComponentRecursive(<entity> entity)
{
if (component.ParentEntity!= null)
{
FetchParentComponentRecursive(entity.ParentEntity);
}
else
{
ultimateparententity = entity;
return component;
}
return entity;
}
I am using variable declared at class level to know the ultimate parent. I am returning variable "Entity" which is never used later, but ultimateparententity is what is used. This approach works, but I am not too happy with this. Any directions will be helpful.
I'm not too familiar with C#, but the general structure of your recursive function looks off.
Try something along the lines of:
internal <entity> FetchParentComponentRecursive(<entity> entity)
{
if (component.ParentEntity == null)
{
return component;
}
else
{
return FetchParentComponentRecursive(entity.ParentEntity);
}
}
By the way, this very much depends on there being no circular references in your data set.
Consider the following program (http://play.golang.org/p/IbAstvudtE):
package main
import (
"fmt"
)
func changeStringValueNotOK(dest *string, src string) {
dest = &src
}
func changeStringValueOK(dest *string, src string) {
*dest = src
}
func main() {
a := "Hello"
b := "World"
changeStringValueNotOK(&a, b)
fmt.Println(a) // still "Hello"
changeStringValueOK(&a, b)
fmt.Println(a) // now "World"
}
My goal is to call a function and change the value of string. Works fine with the second function, but not with the first.
Question: what is the meaning of *dest = src compared to dest = &src? I guess the former is "the contents of dest is now src" and the latter is "change the dest variable so that it now points to the address of src" which discards the previous value, but not the contents of a. But even if I am right, I don't understand how the *dest = src works.
I hope my question isn't too fuzzy.
*dest = src
is: Set the value pointed at by dest to the value in src. So it's effective.
dest = &src
is: Set the value of dest to the address of src. As dest is a formal parameter of changeStringValueNotOK the change (to the pointer only, not to the pointee) is visible only locally. As the changed value is not really used, it's total effect is a no operation.
Just to help visualize it graphically, in your main function you have this:
Data Variables
| ... |
-------
| Hello |<----- <a string>
-------
| World |<----- <b string>
-------
| ... |
When you provide the parameters to either of these functions, it becomes:
Data Parameters
| ... |
-------
| Hello |<----- <a string> <----- <dest *string>
-------
| World |<----------------------- <src string>
-------
| ... |
With that scenario, when you do *dest = src, you get:
Data Parameters
| ... |
-------
| Hello | ,- <a string> <---- <dest *string>
------- |
| World |<--/
| |<---------------------- <src string>
-------
| ... |
Note that this effectively changes a itself, so when you return to the prior scope, you'll observe the change.
On the other hand, if you do dest = &src, you'd instead get:
Data Parameters
| ... |
-------
| Hello | <dest *string> ----,
------- |
| World |<---------------------- <src string> <---/
-------
| ... |
Which doesn't solve your problem, because both dest and src are local to the functions they're in.
As a side note, this kind of parameter passing is a common C idiom, but in Go you'd generally change such a string by returning the new value instead.