Fixed Test

This commit is contained in:
Luca Frosini 2020-05-08 14:52:58 +02:00
parent d986457fbe
commit ede317ca8c
1 changed files with 7 additions and 2 deletions

View File

@ -6,6 +6,7 @@ import java.security.SecureRandom;
import javax.crypto.KeyGenerator;
import org.gcube.informationsystem.ContextTest;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.model.impl.properties.EncryptedImpl;
import org.gcube.informationsystem.model.reference.properties.Encrypted;
import org.gcube.informationsystem.model.reference.properties.Property;
@ -81,8 +82,13 @@ public class EncryptedTest extends ContextTest {
@Test
public void testEncryptedSpecilization() throws Exception {
String marshalled = "{\"@class\":\"MyEncrypted\",\"@superClasses\":[\"Encrypted\", \"Property\"],\"value\":\"Encrypted\"}";
String value = "myValue";
String encryptedValue = EncryptedImpl.encrypt(value);
String marshalled = "{\"" + Element.CLASS_PROPERTY + "\":\"MyEncrypted\",\"" + Element.SUPERCLASSES_PROPERTY + "\":[\"" + Encrypted.NAME + "\", \"" + Property.NAME + "\"],\"" + Encrypted.VALUE + "\":\""+ encryptedValue + "\"}";
Property property = ElementMapper.unmarshal(Property.class, marshalled);
Assert.assertTrue(property instanceof Encrypted);
Encrypted encrypted = (Encrypted) property;
Assert.assertTrue(encrypted.getEncryptedValue().compareTo(encryptedValue)==0);
logger.debug(ElementMapper.marshal(property));
}
@ -94,6 +100,5 @@ public class EncryptedTest extends ContextTest {
logger.debug("Encrypted Value is : '{}' which decrypted is : '{}'", encryptedValue, decryptedValue);
String reEncryptedValue = EncryptedImpl.encrypt(decryptedValue);
Assert.assertTrue(encryptedValue.compareTo(reEncryptedValue)==0);
}
}