Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GRIN-Global CE Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
26
Issues
26
List
Boards
Labels
Service Desk
Milestones
Packages & Registries
Packages & Registries
Container Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
GG-CE
GRIN-Global CE Server
Commits
eeb270fe
Commit
eeb270fe
authored
Nov 27, 2020
by
Maxym Borodenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test: not possible to set accessionNumber/inventoryNumber via API
parent
8175e3ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
2 deletions
+76
-2
src/test/java/org/gringlobal/test/api/v1/AccessionControllerTest.java
...a/org/gringlobal/test/api/v1/AccessionControllerTest.java
+34
-2
src/test/java/org/gringlobal/test/api/v1/InventoryControllerTest.java
...a/org/gringlobal/test/api/v1/InventoryControllerTest.java
+42
-0
No files found.
src/test/java/org/gringlobal/test/api/v1/AccessionControllerTest.java
View file @
eeb270fe
...
...
@@ -28,6 +28,7 @@ import java.util.List;
import
org.apache.commons.lang3.RandomUtils
;
import
org.genesys.blocks.model.JsonViews
;
import
org.gringlobal.api.v1.impl.AccessionController
;
import
org.gringlobal.component.GGCE
;
import
org.gringlobal.model.*
;
import
org.gringlobal.persistence.AccessionInvGroupMapRepository
;
import
org.gringlobal.persistence.AccessionInvGroupRepository
;
...
...
@@ -150,7 +151,7 @@ public class AccessionControllerTest extends AbstractApiV1Test {
mockMvc
.
perform
(
get
(
AccessionController
.
API_URL
.
concat
(
"/details/{id}"
),
savedAccession
.
getId
())
.
contentType
(
MediaType
.
APPLICATION_JSON
))
// .andDo(MockMvcResultHandlers.print())
// .andDo(
org.springframework.test.web.servlet.result.
MockMvcResultHandlers.print())
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON
))
.
andExpect
(
jsonPath
(
"$"
,
not
(
nullValue
())))
...
...
@@ -159,6 +160,7 @@ public class AccessionControllerTest extends AbstractApiV1Test {
.
andExpect
(
jsonPath
(
"$.modifiedBy"
,
is
(
AbstractServicesTest
.
USER_CURATOR1_ID
)))
.
andExpect
(
jsonPath
(
"$.ownedBy"
).
isMap
())
.
andExpect
(
jsonPath
(
"$.ownedBy.id"
,
is
(
AbstractServicesTest
.
USER_CURATOR1_ID
)))
.
andExpect
(
jsonPath
(
"$.accessionNumber"
,
is
(
GGCE
.
accessionNumber
(
savedAccession
))))
.
andExpect
(
jsonPath
(
"$.accessionNumberPart1"
,
is
(
savedAccession
.
getAccessionNumberPart1
())))
.
andExpect
(
jsonPath
(
"$.statusCode"
,
is
(
savedAccession
.
getStatusCode
())))
.
andExpect
(
jsonPath
(
"$.isBackedUp"
,
is
(
TRUE
)))
...
...
@@ -321,7 +323,7 @@ public class AccessionControllerTest extends AbstractApiV1Test {
.
perform
(
get
(
AccessionController
.
API_URL
.
concat
(
"/auditlog/{id}?s=propertyName"
),
savedAccession
.
getId
())
.
contentType
(
MediaType
.
APPLICATION_JSON
)
)
.
andDo
(
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultHandlers
.
print
())
//
.andDo(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print())
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$.totalElements"
,
greaterThan
(
0
)))
.
andExpect
(
jsonPath
(
"$.sort[0]"
,
not
(
nullValue
())))
...
...
@@ -336,4 +338,34 @@ public class AccessionControllerTest extends AbstractApiV1Test {
/*@formatter:on*/
}
@Test
public
void
testCreateAccessionWithAccessionNumber
()
throws
Exception
{
// build accession
Accession
a
=
new
Accession
();
a
.
setAccessionNumberPart1
(
"TVu"
);
a
.
setAccessionNumberPart2
(
1L
);
a
.
setIsBackedUp
(
TRUE
);
a
.
setIsCore
(
TRUE
);
a
.
setIsWebVisible
(
TRUE
);
a
.
setStatusCode
(
ACCESSION_STATUS_CODE
);
a
.
setTaxonomySpecies
(
addTaxonomySpeciesToDB
());
final
String
content
=
verboseMapper
.
writeValueAsString
(
a
).
replace
(
"\"accessionNumber\":null"
,
"\"accessionNumber\":\"mustNotBeSaved\""
);
/*@formatter:off*/
mockMvc
.
perform
(
post
(
AccessionController
.
API_URL
)
.
content
(
content
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
)
// .andDo(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print())
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$"
,
notNullValue
()))
.
andExpect
(
jsonPath
(
"$.id"
,
is
(
greaterThan
(
0
))))
.
andExpect
(
jsonPath
(
"$.accessionNumber"
).
exists
())
.
andExpect
(
jsonPath
(
"$.accessionNumber"
,
is
(
GGCE
.
accessionNumber
(
a
))))
.
andExpect
(
jsonPath
(
"$.accessionNumberPart1"
,
is
(
"TVu"
)))
;
/*@formatter:on*/
}
}
src/test/java/org/gringlobal/test/api/v1/InventoryControllerTest.java
View file @
eeb270fe
...
...
@@ -24,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import
org.genesys.blocks.auditlog.model.AuditAction
;
import
org.genesys.filerepository.model.RepositoryImage
;
import
org.gringlobal.api.v1.impl.InventoryController
;
import
org.gringlobal.component.GGCE
;
import
org.gringlobal.model.Accession
;
import
org.gringlobal.model.AccessionInvAttach
;
import
org.gringlobal.model.AccessionInvName
;
...
...
@@ -503,6 +504,47 @@ public class InventoryControllerTest extends AbstractApiV1Test {
//assertThat(repositoryFileRepository.count(), is(0L));
}
@Test
public
void
testCreateWithInventoryNumber
()
throws
Exception
{
Accession
accession
=
new
Accession
(
makeAccession
().
getId
());
assertThat
(
accession
.
getId
(),
is
(
greaterThan
(
0L
)));
InventoryMaintenancePolicy
policy
=
new
InventoryMaintenancePolicy
(
addInventoryMaintenancePolicyToDB
().
getId
());
assertThat
(
policy
.
getId
(),
is
(
greaterThan
(
0L
)));
Inventory
inventory
=
new
Inventory
();
inventory
.
setAccession
(
accession
);
// only ID
inventory
.
setInventoryMaintPolicy
(
policy
);
// only ID
inventory
.
setInventoryNumberPart1
(
"INV"
);
inventory
.
setInventoryNumberPart2
(
1L
);
inventory
.
setInventoryNumberPart3
(
null
);
inventory
.
setFormTypeCode
(
INVENTORY_FORM_TYPE_CODE_DEFAULT
);
inventory
.
setAvailabilityStatusCode
(
INVENTORY_AVAILABILITY_STATUS_CODE_DEFAULT
);
inventory
.
setIsAutoDeducted
(
TRUE
);
inventory
.
setIsAvailable
(
TRUE
);
inventory
.
setIsDistributable
(
TRUE
);
final
String
content
=
verboseMapper
.
writeValueAsString
(
inventory
).
replace
(
"\"inventoryNumber\":null"
,
"\"inventoryNumber\":\"mustNotBeSaved\""
);
/*@formatter:off*/
mockMvc
.
perform
(
post
(
InventoryController
.
API_URL
)
.
content
(
content
)
.
contentType
(
MediaType
.
APPLICATION_JSON
)
)
// .andDo(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print())
.
andExpect
(
status
().
isOk
())
.
andExpect
(
jsonPath
(
"$"
,
notNullValue
()))
.
andExpect
(
jsonPath
(
"$.id"
,
is
(
greaterThan
(
0
))))
.
andExpect
(
jsonPath
(
"$.inventoryNumber"
).
exists
())
.
andExpect
(
jsonPath
(
"$.inventoryNumber"
,
is
(
GGCE
.
inventoryNumber
(
inventory
))))
.
andExpect
(
jsonPath
(
"$.inventoryNumberPart1"
,
is
(
"INV"
)))
.
andExpect
(
jsonPath
(
"$.inventoryNumberPart2"
,
is
(
1
)))
;
/*@formatter:on*/
}
private
Accession
makeAccession
()
{
Accession
a
=
new
Accession
();
a
.
setAccessionNumberPart1
(
"AccessionNumberPart1"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment