Search in sources :

Example 1 with CmsDocumentBlobSegment

use of gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment in project API by ca-cwds.

the class CmsDocumentBlobSegmentTest method testColumnConstraintsGood.

@Test
public void testColumnConstraintsGood() throws Exception {
    CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment(docHandle, segmentSequence, docBlob);
    Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
    assertEquals(0, violations.size());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) CmsDocumentBlobSegment(gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment) Test(org.junit.Test)

Example 2 with CmsDocumentBlobSegment

use of gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment in project API by ca-cwds.

the class CmsDocumentBlobSegmentTest method testConstraintBlobNull.

// ====================
// BLOB
// ====================
@Test
public void testConstraintBlobNull() throws Exception {
    CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment(docHandle, segmentSequence, null);
    Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
    assertEquals(1, violations.size());
    assertEquals("may not be null", violations.iterator().next().getMessage());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) CmsDocumentBlobSegment(gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment) Test(org.junit.Test)

Example 3 with CmsDocumentBlobSegment

use of gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment in project API by ca-cwds.

the class CmsDocumentBlobSegmentTest method testConstraintDocSegmentPattern.

@Test
public void testConstraintDocSegmentPattern() throws Exception {
    CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment(docHandle, "abcd", docBlob);
    Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
    assertEquals(1, violations.size());
// assertEquals("invalid DOC_HANDLE", violations.iterator().next().getMessage());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) CmsDocumentBlobSegment(gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment) Test(org.junit.Test)

Example 4 with CmsDocumentBlobSegment

use of gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment in project API by ca-cwds.

the class CmsDocumentBlobSegmentTest method testConstraintDocHandlePattern.

// ====================
// DOC_HANDLE
// ====================
@Test
public void testConstraintDocHandlePattern() throws Exception {
    CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment("123456789012345678901234567890", segmentSequence, docBlob);
    Set<ConstraintViolation<CmsDocumentBlobSegment>> violations = validator.validate(blob);
    assertEquals(1, violations.size());
    assertEquals("invalid DOC_HANDLE", violations.iterator().next().getMessage());
}
Also used : ConstraintViolation(javax.validation.ConstraintViolation) CmsDocumentBlobSegment(gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment) Test(org.junit.Test)

Example 5 with CmsDocumentBlobSegment

use of gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment in project API by ca-cwds.

the class CmsDocumentBlobSegmentTest method testGetPrimaryKeyGood.

@Test
public void testGetPrimaryKeyGood() throws Exception {
    VarargPrimaryKey pk = new VarargPrimaryKey(docHandle, segmentSequence);
    CmsDocumentBlobSegment blob = new CmsDocumentBlobSegment(docHandle, segmentSequence, docBlob);
    assertThat(blob.getPrimaryKey().toString(), is(equalTo(pk.toString())));
}
Also used : CmsDocumentBlobSegment(gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment) VarargPrimaryKey(gov.ca.cwds.data.persistence.cms.VarargPrimaryKey) Test(org.junit.Test)

Aggregations

CmsDocumentBlobSegment (gov.ca.cwds.data.persistence.cms.CmsDocumentBlobSegment)15 Test (org.junit.Test)13 ConstraintViolation (javax.validation.ConstraintViolation)10 ServiceException (gov.ca.cwds.rest.services.ServiceException)2 CmsDocument (gov.ca.cwds.data.persistence.cms.CmsDocument)1 VarargPrimaryKey (gov.ca.cwds.data.persistence.cms.VarargPrimaryKey)1 CmsPKCompressor (gov.ca.cwds.rest.util.jni.CmsPKCompressor)1 LZWEncoder (gov.ca.cwds.rest.util.jni.LZWEncoder)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 ExpectedException (org.hamcrest.junit.ExpectedException)1