use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.
the class Manager method createUser.
/**
* Create a user with the specified {@code username}, {@code password} and
* {@code role}.
*
* @param username
* @param password
* @param role
*/
public void createUser(String username, String password, String role) {
ByteBuffer uname = ByteBuffers.fromUtf8String(username);
ByteBuffer pword = ByteBuffers.fromUtf8String(password);
List<ComplexTObject> params = ImmutableList.of(ComplexTObject.fromJavaObject(uname), ComplexTObject.fromJavaObject(pword), ComplexTObject.fromJavaObject(role));
concourse.execute(() -> concourse.$core().invokeManagement("createUser", params, concourse.creds()));
}
use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.
the class Manager method grant.
/**
* Grant the {@code permission} to the user with {@code username} in the
* specified {@code environment}.
*
* @param username
* @param permission
* @param environment
*/
public void grant(String username, String permission, String environment) {
ByteBuffer uname = ByteBuffers.fromUtf8String(username);
List<ComplexTObject> params = ImmutableList.of(ComplexTObject.fromJavaObject(uname), ComplexTObject.fromJavaObject(permission), ComplexTObject.fromJavaObject(environment));
concourse.execute(() -> concourse.$core().invokeManagement("grant", params, concourse.creds()));
}
use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.
the class LazyTrackingTObjectResultDatasetTest method testSerializationRepro.
@Test
public void testSerializationRepro() {
String json = FileOps.read(Resources.getAbsolutePath("/data.json"));
List<Multimap<String, Object>> objects = Convert.anyJsonToJava(json);
for (Multimap<String, Object> object : objects) {
long entity = Time.now();
for (Entry<String, Collection<Object>> entry : object.asMap().entrySet()) {
String attribute = entry.getKey();
for (Object value : entry.getValue()) {
dataset.insert(entity, attribute, Convert.javaToThrift(value));
}
}
}
PluginSerializer serializer = new PluginSerializer();
ByteBuffer bytes = serializer.serialize(dataset);
ComplexTObject complex = ComplexTObject.fromJavaObject(bytes);
ByteBuffer bytes2 = complex.getJavaObject();
Object obj = serializer.deserialize(bytes2);
Assert.assertEquals(dataset, obj);
}
use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.
the class ObjectResultDatasetTest method testSerialization.
@Test
public void testSerialization() {
ObjectResultDataset dataset = new ObjectResultDataset(new TObjectResultDataset());
dataset.insert(1L, "name", "Jeff Nelson");
PluginSerializer serializer = new PluginSerializer();
ByteBuffer bytes = serializer.serialize(dataset);
ComplexTObject complex = ComplexTObject.fromJavaObject(bytes);
ByteBuffer bytes2 = complex.getJavaObject();
Object obj = serializer.deserialize(bytes2);
Assert.assertEquals(dataset, obj);
}
use of com.cinchapi.concourse.thrift.ComplexTObject in project concourse by cinchapi.
the class PluginSerializerTest method testSerializeComplexTObject.
@Test
public void testSerializeComplexTObject() {
int count = Random.getScaleCount();
List<TObject> list = Lists.newArrayListWithCapacity(count);
for (int i = 0; i < count; ++i) {
list.add(Convert.javaToThrift(Random.getObject()));
}
ComplexTObject expected = ComplexTObject.fromJavaObject(list);
ByteBuffer buffer = serializer.serialize(expected);
ComplexTObject actual = serializer.deserialize(buffer);
Assert.assertEquals(expected, actual);
}
Aggregations