use of org.junit.jupiter.params.provider.MethodSource in project janusgraph by JanusGraph.
the class RelationIdentifierGraphBinarySerializerTest method readValueAndWriteValueShouldBeSymmetric.
@ParameterizedTest
@MethodSource("relationIdentifierProvider")
public void readValueAndWriteValueShouldBeSymmetric(final RelationIdentifier relationIdentifier) throws IOException {
final TypeSerializerRegistry registry = TypeSerializerRegistry.build().addCustomType(RelationIdentifier.class, new RelationIdentifierGraphBinarySerializer()).create();
final GraphBinaryReader reader = new GraphBinaryReader(registry);
final GraphBinaryWriter writer = new GraphBinaryWriter(registry);
for (boolean nullable : new boolean[] { true, false }) {
final Buffer buffer = bufferFactory.create(allocator.buffer());
writer.writeValue(relationIdentifier, buffer, nullable);
final RelationIdentifier actual = reader.readValue(buffer, RelationIdentifier.class, nullable);
assertEquals(actual.toString(), relationIdentifier.toString());
buffer.release();
}
}
use of org.junit.jupiter.params.provider.MethodSource in project janusgraph by JanusGraph.
the class JanusGraphPGraphBinarySerializerTest method readValueAndWriteValueShouldBeSymmetric.
@ParameterizedTest
@MethodSource("janusGraphPProvider")
public void readValueAndWriteValueShouldBeSymmetric(final JanusGraphP predicate) throws IOException {
final TypeSerializerRegistry registry = TypeSerializerRegistry.build().addCustomType(JanusGraphP.class, new JanusGraphPBinarySerializer()).addCustomType(Geoshape.class, new GeoshapeGraphBinarySerializer()).create();
final GraphBinaryReader reader = new GraphBinaryReader(registry);
final GraphBinaryWriter writer = new GraphBinaryWriter(registry);
for (boolean nullable : new boolean[] { true, false }) {
final Buffer buffer = bufferFactory.create(allocator.buffer());
writer.writeValue(predicate, buffer, nullable);
final JanusGraphP actual = reader.readValue(buffer, JanusGraphP.class, nullable);
assertEquals(actual.toString(), predicate.toString());
buffer.release();
}
}
use of org.junit.jupiter.params.provider.MethodSource in project OpenGrok by OpenGrok.
the class UserWhiteListPluginTest method shouldNotAllowRandomUserForAnyGroup.
@ParameterizedTest
@MethodSource("parameters")
public void shouldNotAllowRandomUserForAnyGroup(String param) {
init(param);
plugin.load(validPluginParameters);
DummyHttpServletRequest req = new DummyHttpServletRequest();
req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
boolean projectAllowed = plugin.isAllowed(req, randomGroup);
assertFalse(projectAllowed, "should not allow random group 1");
randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
projectAllowed = plugin.isAllowed(req, randomGroup);
assertFalse(projectAllowed, "should not allow random group 2");
}
use of org.junit.jupiter.params.provider.MethodSource in project OpenGrok by OpenGrok.
the class UserWhiteListPluginTest method shouldAllowWhitelistedUserForAnyGroup.
@ParameterizedTest
@MethodSource("parameters")
public void shouldAllowWhitelistedUserForAnyGroup(String param) {
init(param);
plugin.load(validPluginParameters);
DummyHttpServletRequest req = new DummyHttpServletRequest();
User user;
if (param.equals(UserWhiteListPlugin.USERNAME_FIELD)) {
user = new User(OK_USER);
} else {
user = new User("blurb", OK_ID);
}
req.setAttribute(UserPlugin.REQUEST_ATTR, user);
Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
boolean groupAllowed = plugin.isAllowed(req, randomGroup);
assertTrue(groupAllowed, "should allow OK entity for random group 1");
randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
groupAllowed = plugin.isAllowed(req, randomGroup);
assertTrue(groupAllowed, "should allow OK entity for random group 2");
}
use of org.junit.jupiter.params.provider.MethodSource in project OpenGrok by OpenGrok.
the class UserWhiteListPluginTest method shouldAllowWhitelistedUserForAnyProject.
@ParameterizedTest
@MethodSource("parameters")
public void shouldAllowWhitelistedUserForAnyProject(String param) {
init(param);
plugin.load(validPluginParameters);
DummyHttpServletRequest req = new DummyHttpServletRequest();
User user;
if (param.equals(UserWhiteListPlugin.USERNAME_FIELD)) {
user = new User(OK_USER);
} else {
user = new User("blurb", OK_ID);
}
req.setAttribute(UserPlugin.REQUEST_ATTR, user);
Project randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
boolean projectAllowed = plugin.isAllowed(req, randomProject);
assertTrue(projectAllowed, "should allow OK entity for random project 1");
randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
projectAllowed = plugin.isAllowed(req, randomProject);
assertTrue(projectAllowed, "should allow OK entity for random project 2");
}
Aggregations