Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
3819b2f4
Commit
3819b2f4
authored
11 years ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SP-625 BIS-398: Test Fixes. Ongoing work.
SVN: 29166
parent
b4fb5651
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java
+103
-79
103 additions, 79 deletions
...ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java
with
103 additions
and
79 deletions
openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java
+
103
−
79
View file @
3819b2f4
...
@@ -196,92 +196,18 @@ public class CommonServerTest extends SystemTestCase
...
@@ -196,92 +196,18 @@ public class CommonServerTest extends SystemTestCase
@Test
@Test
public
void
testRegisterEntitytypeAndAssignPropertyTypes
()
throws
Exception
public
void
testRegisterEntitytypeAndAssignPropertyTypes
()
throws
Exception
{
{
for
(
EntityKind
entityKind
:
EntityKind
.
values
())
registerEntitytypeAndAssignPropertyTypesWithId
(
0
);
{
// Entity Type
final
String
entityTypeCode
=
"TEST_ENTITY_TYPE_CODE_"
+
entityKind
.
name
();
EntityType
entityType
=
null
;
switch
(
entityKind
)
{
case
EXPERIMENT:
entityType
=
new
ExperimentType
();
((
ExperimentType
)
entityType
).
setExperimentTypePropertyTypes
(
new
ArrayList
<
ExperimentTypePropertyType
>());
break
;
case
DATA_SET:
entityType
=
new
DataSetType
();
((
DataSetType
)
entityType
).
setDataSetKind
(
DataSetKind
.
PHYSICAL
);
((
DataSetType
)
entityType
).
setDataSetTypePropertyTypes
(
new
ArrayList
<
DataSetTypePropertyType
>());
break
;
case
MATERIAL:
entityType
=
new
MaterialType
();
((
MaterialType
)
entityType
).
setMaterialTypePropertyTypes
(
new
ArrayList
<
MaterialTypePropertyType
>());
break
;
case
SAMPLE:
entityType
=
new
SampleType
();
((
SampleType
)
entityType
).
setGeneratedCodePrefix
(
"TEST"
);
((
SampleType
)
entityType
).
setSampleTypePropertyTypes
(
new
ArrayList
<
SampleTypePropertyType
>());
break
;
}
entityType
.
setCode
(
entityTypeCode
);
// Complete Assignments Object
NewETNewPTAssigments
assigments
=
new
NewETNewPTAssigments
();
assigments
.
setEntity
(
entityType
);
assigments
.
setAssigments
(
new
ArrayList
<
NewPTNewAssigment
>());
Random
random
=
new
Random
();
final
int
numberOfProperties
=
random
.
nextInt
(
20
)
+
1
;
for
(
int
i
=
0
;
i
<
numberOfProperties
;
i
++)
{
// Property Type
final
String
propertyTypeCode
=
"TEST_PROPERTY_TYPE_CODE_"
+
random
.
nextInt
();
final
String
propertyTypeLabel
=
"TEST_PROPERTY_TYPE_LABEL_"
+
random
.
nextInt
();
final
String
propertyTypeDescription
=
"TEST_PROPERTY_TYPE_DESCRIPTION_"
+
random
.
nextInt
();
final
DataType
dataType
=
new
DataType
();
dataType
.
setCode
(
DataTypeCode
.
INTEGER
);
PropertyType
newPropertyType
=
new
PropertyType
();
newPropertyType
.
setCode
(
propertyTypeCode
);
newPropertyType
.
setLabel
(
propertyTypeLabel
);
newPropertyType
.
setDescription
(
propertyTypeDescription
);
newPropertyType
.
setDataType
(
dataType
);
// New Assignments
NewETPTAssignment
newETPTAssigment
=
new
NewETPTAssignment
();
newETPTAssigment
.
setEntityKind
(
entityKind
);
newETPTAssigment
.
setPropertyTypeCode
(
propertyTypeCode
);
newETPTAssigment
.
setEntityTypeCode
(
entityTypeCode
);
newETPTAssigment
.
setOrdinal
((
long
)
assigments
.
getAssigments
().
size
());
NewPTNewAssigment
newPTNewAssigment
=
new
NewPTNewAssigment
();
newPTNewAssigment
.
setExistingPropertyType
(
false
);
newPTNewAssigment
.
setPropertyType
(
newPropertyType
);
newPTNewAssigment
.
setAssignment
(
newETPTAssigment
);
assigments
.
refreshOrderAdd
(
newPTNewAssigment
);
}
// Call
commonServer
.
registerEntitytypeAndAssignPropertyTypes
(
systemSessionToken
,
assigments
);
// Validation
List
<
EntityTypePropertyType
<?>>
listAssigments
=
commonServer
.
listEntityTypePropertyTypes
(
systemSessionToken
,
entityType
);
for
(
int
i
=
0
;
i
<
assigments
.
getAssigments
().
size
();
i
++)
{
assertEquals
(
assigments
.
getAssigments
().
get
(
i
).
getPropertyType
(),
listAssigments
.
get
(
i
).
getPropertyType
());
}
}
}
}
@Test
@Test
public
void
testUpdateEntitytypeAndPropertyTypes
()
throws
Exception
public
void
testUpdateEntitytypeAndPropertyTypes
()
throws
Exception
{
{
testRegisterEntitytypeAndAssignPropertyTypes
();
int
testId
=
1
;
registerEntitytypeAndAssignPropertyTypesWithId
(
testId
);
for
(
EntityKind
entityKind
:
EntityKind
.
values
())
for
(
EntityKind
entityKind
:
EntityKind
.
values
())
{
{
// Existing Entity Type
// Existing Entity Type
final
String
entityTypeCode
=
"TEST_ENTITY_TYPE_CODE_"
+
entityKind
.
name
();
final
String
entityTypeCode
=
"TEST_ENTITY_TYPE_CODE_"
+
entityKind
.
name
()
+
"_"
+
testId
;
List
<?
extends
EntityType
>
types
=
null
;
List
<?
extends
EntityType
>
types
=
null
;
EntityType
entityType
=
null
;
EntityType
entityType
=
null
;
...
@@ -420,9 +346,107 @@ public class CommonServerTest extends SystemTestCase
...
@@ -420,9 +346,107 @@ public class CommonServerTest extends SystemTestCase
assertEquals
(
assigments
.
getAssigments
().
size
(),
listAssigments
.
size
());
assertEquals
(
assigments
.
getAssigments
().
size
(),
listAssigments
.
size
());
for
(
int
i
=
0
;
i
<
assigments
.
getAssigments
().
size
();
i
++)
for
(
int
i
=
0
;
i
<
assigments
.
getAssigments
().
size
();
i
++)
{
{
assertEquals
(
assigments
.
getAssigments
().
get
(
i
).
getPropertyType
(),
listAssigments
.
get
(
i
).
getPropertyType
());
if
(
assigments
.
getAssigments
().
get
(
i
).
getPropertyType
().
getCode
().
equals
(
listAssigments
.
get
(
i
).
getPropertyType
().
getCode
())
||
isContained
(
assigments
.
getAssigments
().
get
(
i
).
getPropertyType
(),
listAssigments
))
{
// Cool, is ok
}
else
{
throw
new
AssertionError
(
"Not contained in list"
);
}
}
}
}
}
}
}
public
static
boolean
isContained
(
PropertyType
propertyType
,
List
<
EntityTypePropertyType
<?>>
inList
)
{
for
(
EntityTypePropertyType
etpt
:
inList
)
{
if
(
etpt
.
getPropertyType
().
getCode
().
equals
(
propertyType
.
getCode
()))
{
return
true
;
}
}
return
false
;
}
public
void
registerEntitytypeAndAssignPropertyTypesWithId
(
int
testId
)
throws
Exception
{
for
(
EntityKind
entityKind
:
EntityKind
.
values
())
{
// Entity Type
final
String
entityTypeCode
=
"TEST_ENTITY_TYPE_CODE_"
+
entityKind
.
name
()
+
"_"
+
testId
;
EntityType
entityType
=
null
;
switch
(
entityKind
)
{
case
EXPERIMENT:
entityType
=
new
ExperimentType
();
((
ExperimentType
)
entityType
).
setExperimentTypePropertyTypes
(
new
ArrayList
<
ExperimentTypePropertyType
>());
break
;
case
DATA_SET:
entityType
=
new
DataSetType
();
((
DataSetType
)
entityType
).
setDataSetKind
(
DataSetKind
.
PHYSICAL
);
((
DataSetType
)
entityType
).
setDataSetTypePropertyTypes
(
new
ArrayList
<
DataSetTypePropertyType
>());
break
;
case
MATERIAL:
entityType
=
new
MaterialType
();
((
MaterialType
)
entityType
).
setMaterialTypePropertyTypes
(
new
ArrayList
<
MaterialTypePropertyType
>());
break
;
case
SAMPLE:
entityType
=
new
SampleType
();
((
SampleType
)
entityType
).
setGeneratedCodePrefix
(
"TEST"
);
((
SampleType
)
entityType
).
setSampleTypePropertyTypes
(
new
ArrayList
<
SampleTypePropertyType
>());
break
;
}
entityType
.
setCode
(
entityTypeCode
);
// Complete Assignments Object
NewETNewPTAssigments
assigments
=
new
NewETNewPTAssigments
();
assigments
.
setEntity
(
entityType
);
assigments
.
setAssigments
(
new
ArrayList
<
NewPTNewAssigment
>());
Random
random
=
new
Random
();
final
int
numberOfProperties
=
random
.
nextInt
(
20
)
+
1
;
for
(
int
i
=
0
;
i
<
numberOfProperties
;
i
++)
{
// Property Type
final
String
propertyTypeCode
=
"TEST_PROPERTY_TYPE_CODE_"
+
random
.
nextInt
();
final
String
propertyTypeLabel
=
"TEST_PROPERTY_TYPE_LABEL_"
+
random
.
nextInt
();
final
String
propertyTypeDescription
=
"TEST_PROPERTY_TYPE_DESCRIPTION_"
+
random
.
nextInt
();
final
DataType
dataType
=
new
DataType
();
dataType
.
setCode
(
DataTypeCode
.
INTEGER
);
PropertyType
newPropertyType
=
new
PropertyType
();
newPropertyType
.
setCode
(
propertyTypeCode
);
newPropertyType
.
setLabel
(
propertyTypeLabel
);
newPropertyType
.
setDescription
(
propertyTypeDescription
);
newPropertyType
.
setDataType
(
dataType
);
// New Assignments
NewETPTAssignment
newETPTAssigment
=
new
NewETPTAssignment
();
newETPTAssigment
.
setEntityKind
(
entityKind
);
newETPTAssigment
.
setPropertyTypeCode
(
propertyTypeCode
);
newETPTAssigment
.
setEntityTypeCode
(
entityTypeCode
);
newETPTAssigment
.
setOrdinal
((
long
)
assigments
.
getAssigments
().
size
());
NewPTNewAssigment
newPTNewAssigment
=
new
NewPTNewAssigment
();
newPTNewAssigment
.
setExistingPropertyType
(
false
);
newPTNewAssigment
.
setPropertyType
(
newPropertyType
);
newPTNewAssigment
.
setAssignment
(
newETPTAssigment
);
assigments
.
refreshOrderAdd
(
newPTNewAssigment
);
}
// Call
commonServer
.
registerEntitytypeAndAssignPropertyTypes
(
systemSessionToken
,
assigments
);
// Validation
List
<
EntityTypePropertyType
<?>>
listAssigments
=
commonServer
.
listEntityTypePropertyTypes
(
systemSessionToken
,
entityType
);
for
(
int
i
=
0
;
i
<
assigments
.
getAssigments
().
size
();
i
++)
{
assertEquals
(
assigments
.
getAssigments
().
get
(
i
).
getPropertyType
(),
listAssigments
.
get
(
i
).
getPropertyType
());
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment