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
87e3f067
Commit
87e3f067
authored
11 years ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SP-625 BIS-398: Basic tests for new API calls. Ongoing work.
SVN: 29145
parent
82f44bf8
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
+218
-1
218 additions, 1 deletion
...ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java
with
218 additions
and
1 deletion
openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java
+
218
−
1
View file @
87e3f067
...
@@ -25,14 +25,25 @@ import java.util.List;
...
@@ -25,14 +25,25 @@ import java.util.List;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.TechId
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.TechId
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.ContainerDataSet
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.ContainerDataSet
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetKind
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityTypePropertyType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityTypePropertyType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.MaterialType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewETNewPTAssigments
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewETPTAssignment
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.NewPTNewAssigment
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType
;
/**
/**
* @author Franz-Josef Elmer
* @author Franz-Josef Elmer
...
@@ -135,4 +146,210 @@ public class CommonServerTest extends SystemTestCase
...
@@ -135,4 +146,210 @@ public class CommonServerTest extends SystemTestCase
Collections
.
sort
(
propertyCodes
);
Collections
.
sort
(
propertyCodes
);
assertEquals
(
expected
,
propertyCodes
.
toString
());
assertEquals
(
expected
,
propertyCodes
.
toString
());
}
}
@Test
public
void
testRegisterAndAssignPropertyType
()
{
// Entity Type
final
String
entityTypeCode
=
"TEST_ENTITY_TYPE_CODE_"
+
System
.
currentTimeMillis
();
final
EntityKind
entityKind
=
EntityKind
.
EXPERIMENT
;
ExperimentType
entityType
=
new
ExperimentType
();
entityType
.
setCode
(
entityTypeCode
);
// Property Type
final
String
propertyTypeCode
=
"TEST_PROPERTY_TYPE_CODE_"
+
System
.
currentTimeMillis
();
final
String
propertyTypeLabel
=
"TEST_PROPERTY_TYPE_LABEL_"
+
System
.
currentTimeMillis
();
final
String
propertyTypeDescription
=
"TEST_PROPERTY_TYPE_DESCRIPTION_"
+
System
.
currentTimeMillis
();
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
);
// Assigment
NewETPTAssignment
newETPTAssigment
=
new
NewETPTAssignment
();
newETPTAssigment
.
setEntityKind
(
entityKind
);
newETPTAssigment
.
setPropertyTypeCode
(
propertyTypeCode
);
newETPTAssigment
.
setEntityTypeCode
(
entityTypeCode
);
newETPTAssigment
.
setOrdinal
(
0L
);
// Call
commonServer
.
registerExperimentType
(
systemSessionToken
,
entityType
);
commonServer
.
registerAndAssignPropertyType
(
systemSessionToken
,
newPropertyType
,
newETPTAssigment
);
// Validation
List
<
EntityTypePropertyType
<?>>
listAssigments
=
commonServer
.
listEntityTypePropertyTypes
(
systemSessionToken
,
entityType
);
assertEquals
(
newPropertyType
,
listAssigments
.
get
(
0
).
getPropertyType
());
}
@Test
public
void
testRegisterEntitytypeAndAssignPropertyTypes
()
{
for
(
EntityKind
entityKind
:
EntityKind
.
values
())
{
// Entity Type
final
String
entityTypeCode
=
"TEST_ENTITY_TYPE_CODE_"
+
entityKind
.
name
();
EntityType
entityType
=
null
;
switch
(
entityKind
)
{
case
EXPERIMENT:
entityType
=
new
ExperimentType
();
break
;
case
DATA_SET:
entityType
=
new
DataSetType
();
((
DataSetType
)
entityType
).
setDataSetKind
(
DataSetKind
.
PHYSICAL
);
break
;
case
MATERIAL:
entityType
=
new
MaterialType
();
break
;
case
SAMPLE:
entityType
=
new
SampleType
();
((
SampleType
)
entityType
).
setGeneratedCodePrefix
(
"TEST"
);
break
;
}
entityType
.
setCode
(
entityTypeCode
);
// Property Type
final
String
propertyTypeCode
=
"TEST_PROPERTY_TYPE_CODE_"
+
System
.
currentTimeMillis
();
final
String
propertyTypeLabel
=
"TEST_PROPERTY_TYPE_LABEL_"
+
System
.
currentTimeMillis
();
final
String
propertyTypeDescription
=
"TEST_PROPERTY_TYPE_DESCRIPTION_"
+
System
.
currentTimeMillis
();
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
(
0L
);
NewPTNewAssigment
newPTNewAssigment
=
new
NewPTNewAssigment
();
newPTNewAssigment
.
setExistingPropertyType
(
false
);
newPTNewAssigment
.
setPropertyType
(
newPropertyType
);
newPTNewAssigment
.
setAssignment
(
newETPTAssigment
);
// Complete Assignments Object
NewETNewPTAssigments
assigments
=
new
NewETNewPTAssigments
();
assigments
.
setEntity
(
entityType
);
List
<
NewPTNewAssigment
>
assigmentsList
=
new
ArrayList
<
NewPTNewAssigment
>();
assigmentsList
.
add
(
newPTNewAssigment
);
assigments
.
setAssigments
(
assigmentsList
);
// Call
commonServer
.
registerEntitytypeAndAssignPropertyTypes
(
systemSessionToken
,
assigments
);
// Validation
List
<
EntityTypePropertyType
<?>>
listAssigments
=
commonServer
.
listEntityTypePropertyTypes
(
systemSessionToken
,
entityType
);
assertEquals
(
newPropertyType
,
listAssigments
.
get
(
0
).
getPropertyType
());
}
}
@Test
public
void
testUpdateEntitytypeAndPropertyTypes
()
throws
Exception
{
testRegisterEntitytypeAndAssignPropertyTypes
();
for
(
EntityKind
entityKind
:
EntityKind
.
values
())
{
// Existing Entity Type
final
String
entityTypeCode
=
"TEST_ENTITY_TYPE_CODE_"
+
entityKind
.
name
();
List
<?
extends
EntityType
>
types
=
null
;
EntityType
entityType
=
null
;
switch
(
entityKind
)
{
case
EXPERIMENT:
types
=
commonServer
.
listExperimentTypes
(
systemSessionToken
);
break
;
case
DATA_SET:
types
=
commonServer
.
listDataSetTypes
(
systemSessionToken
);
break
;
case
MATERIAL:
types
=
commonServer
.
listMaterialTypes
(
systemSessionToken
);
break
;
case
SAMPLE:
types
=
commonServer
.
listSampleTypes
(
systemSessionToken
);
break
;
}
for
(
EntityType
type
:
types
)
{
if
(
type
.
getCode
().
equals
(
entityTypeCode
))
{
entityType
=
type
;
}
}
// Complete Assignments Object
NewETNewPTAssigments
assigments
=
new
NewETNewPTAssigments
();
assigments
.
setEntity
(
entityType
);
entityType
.
getAssignedPropertyTypes
().
clear
();
assigments
.
setAssigments
(
new
ArrayList
<
NewPTNewAssigment
>());
// Existing Assignments
List
<
EntityTypePropertyType
<?>>
listAssigmentsOld
=
commonServer
.
listEntityTypePropertyTypes
(
systemSessionToken
,
entityType
);
for
(
int
i
=
0
;
i
<
listAssigmentsOld
.
size
();
i
++)
{
NewETPTAssignment
oldETPTAssigment
=
new
NewETPTAssignment
();
oldETPTAssigment
.
setEntityKind
(
listAssigmentsOld
.
get
(
i
).
getEntityKind
());
oldETPTAssigment
.
setPropertyTypeCode
(
listAssigmentsOld
.
get
(
i
).
getPropertyType
().
getCode
());
oldETPTAssigment
.
setEntityTypeCode
(
listAssigmentsOld
.
get
(
i
).
getEntityType
().
getCode
());
oldETPTAssigment
.
setOrdinal
((
long
)
i
);
NewPTNewAssigment
oldPTNewAssigment
=
new
NewPTNewAssigment
();
oldPTNewAssigment
.
setExistingPropertyType
(
true
);
oldPTNewAssigment
.
setPropertyType
(
listAssigmentsOld
.
get
(
i
).
getPropertyType
());
oldPTNewAssigment
.
setAssignment
(
oldETPTAssigment
);
assigments
.
refreshOrderAdd
(
oldPTNewAssigment
);
}
// New Assignments
final
String
propertyTypeCode
=
"TEST_PROPERTY_TYPE_CODE_"
+
System
.
currentTimeMillis
();
final
String
propertyTypeLabel
=
"TEST_PROPERTY_TYPE_LABEL_"
+
System
.
currentTimeMillis
();
final
String
propertyTypeDescription
=
"TEST_PROPERTY_TYPE_DESCRIPTION_"
+
System
.
currentTimeMillis
();
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
);
NewETPTAssignment
newETPTAssigment
=
new
NewETPTAssignment
();
newETPTAssigment
.
setEntityKind
(
entityKind
);
newETPTAssigment
.
setPropertyTypeCode
(
propertyTypeCode
);
newETPTAssigment
.
setEntityTypeCode
(
entityTypeCode
);
newETPTAssigment
.
setOrdinal
((
long
)
assigments
.
getAssigments
().
size
());
NewPTNewAssigment
newPTNewassignment
=
new
NewPTNewAssigment
();
newPTNewassignment
.
setExistingPropertyType
(
false
);
newPTNewassignment
.
setPropertyType
(
newPropertyType
);
newPTNewassignment
.
setAssignment
(
newETPTAssigment
);
assigments
.
refreshOrderAdd
(
newPTNewassignment
);
// Call
commonServer
.
updateEntitytypeAndPropertyTypes
(
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