id stringlengths 8 13 | source stringlengths 164 33.1k | target stringlengths 36 5.98k |
|---|---|---|
486214_0 | class CommonSource extends ReflectiveExpressionSource {
@Property
public Object emit()
{
return Attribute.ATTR_EMIT;
}
@Inject public CommonSource(Stage stage);
@Property public Object skip();
@Method public String urlencode(String in);
@Method("urlencode") public String urlencodeInput(@Instance String in... | Assert.assertEquals(Attribute.ATTR_EMIT, execute("t:emit", ""));
Assert.assertEquals(Attribute.ATTR_EMIT, execute("true ? t:emit", ""));
}
} |
486214_1 | class CommonSource extends ReflectiveExpressionSource {
@Property
public Object skip()
{
return Attribute.ATTR_SKIP;
}
@Inject public CommonSource(Stage stage);
@Property public Object emit();
@Method public String urlencode(String in);
@Method("urlencode") public String urlencodeInput(@Instance String in... | Assert.assertEquals(Attribute.ATTR_SKIP, execute("t:skip", ""));
Assert.assertEquals(Attribute.ATTR_SKIP, execute("true ? t:skip", ""));
}
} |
781084_0 | class WebHookSecurityInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
return webHookAdapter.isValidRequest(request);
}
}
class TestWebHookSecurityInterceptor {
@Test
public vo... | MyTestWebHookAdapter adapter = new MyTestWebHookAdapter();
WebHookSecurityInterceptor interceptor = new WebHookSecurityInterceptor();
// set the adapter like spring would do.
Field field = WebHookSecurityInterceptor.class.getDeclaredField("webHookAdapter");
field.setAccessible(true);
field.set(i... |
854893_4 | class Converters {
public static <T, V> Converter<T, V> get(Class<T> from, Class<V> to) {
if (to == Integer.class || to == int.class) {
if (from == Byte.class || from == byte.class) {
return (Converter<T, V>) byteToInteger;
} else if (from == Short.class || from == s... | assertNull(Converters.get(String.class, Boolean.class));
Converter<Byte, Integer> converter1 = Converters.get(Byte.class, Integer.class);
assertNotNull(converter1);
assertEquals(new Integer(3), converter1.convert(new Byte((byte) 3)));
Converter<Short, Integer> converter2 = Conver... |
854893_5 | class VariableContext implements ReferenceContext<VariableResolver> {
public Reference<VariableResolver> selectAttribute(String name) {
return new VariableReference(name, this);
}
public VariableContext(VariableDefinitions defs);
public Reference<VariableResolver> selectItem(String index);
... | final Data data = new Data();
data.data = new Data();
data.data.str = "foobar";
VariableDefinitions defs = new DataVariableDefinitions();
VariableContext context = new VariableContext(defs);
Reference<VariableResolver> reference = context.selectAttribute("data");
... |
854893_7 | class MultiReference implements Reference<E> {
public Reference<E> narrow(Class<?> type) throws BindingException {
List<Reference<E>> resulting = new ArrayList<Reference<E>>();
for (Reference<E> reference :references) {
Reference<E> result = reference.narrow(type);
if (resul... | StringBuilder builder = new StringBuilder();
Document document = new StringBuilderDocument(builder);
String propertyName = "pi";
expect(reference1.narrow(String.class)).andReturn(reference1);
expect(reference2.narrow(String.class)).andReturn(reference2);
expect(reference1... |
1552601_0 | class FilePublicKeyProvider extends AbstractKeyPairProvider {
public Iterable<KeyPair> loadKeys() {
if (!SecurityUtils.isBouncyCastleRegistered()) {
throw new IllegalStateException("BouncyCastle must be registered as a JCE provider");
}
List<KeyPair> keys = new ArrayList<KeyPair>();
for (String... | String pubKeyFile = Thread.currentThread().getContextClassLoader().getResource("test_authorized_key.pem").getFile();
assertTrue(new File(pubKeyFile).exists());
FilePublicKeyProvider SUT = new FilePublicKeyProvider(new String[]{pubKeyFile});
assertTrue(SUT.loadKeys().iterator().hasNext());
}
} |
1556938_0 | class Erector {
public BlueprintTemplate getTemplate() {
return blueprintTemplate;
}
public Erector();
public Object createNewInstance();
public void addCommands(ModelField modelField, Set<Command> commands);
public void addCommand( ModelField modelField, Command command );
public Set<Command> getCommands(... | Car car = new Car();
car.setMileage(new Float(123.456));
Float val = (Float) erector.getTemplate().get(car, "mileage");
assertEquals(new Float(123.456), val);
}
} |
1644710_0 | class RestBuilder {
public Model buildModel(Iterable<NamedInputSupplier> suppliers) throws IOException {
List<Model> models = Lists.newArrayList();
for (NamedInputSupplier supplier : suppliers) {
Model model = buildModel(supplier);
models.add(model);
}
retur... |
assertThat(model)
.describedAs("A restbuilder model object")
.isNotNull()
.isInstanceOf(Model.class);
assertThat(model.getNamespace()).isEqualTo("example");
assertThat(model.getOperations()).isNotEmpty().hasSize(2);
Resource accountResou... |
2017533_0 | class FlacAudioFileReader extends AudioFileReader {
public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
InputStream inputStream = new FileInputStream(file);
try {
return getAudioInputStream(inputStream, (int) file.length());
... | final FlacAudioFileReader flacAudioFileReader = new FlacAudioFileReader();
final AudioInputStream stream = flacAudioFileReader.getAudioInputStream(getFlacTestFile("cymbals.flac"));
assertNotNull(stream);
}
} |
2017533_1 | class FlacAudioFileReader extends AudioFileReader {
public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
InputStream inputStream = new FileInputStream(file);
try {
return getAudioInputStream(inputStream, (int) file.length());
... | final FlacAudioFileReader flacAudioFileReader = new FlacAudioFileReader();
final File flacTestFile = getFlacTestFile("cymbals.flac");
InputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(flacTestFile));
assertTrue("For this test the strea... |
2017533_2 | class FlacAudioFileReader extends AudioFileReader {
public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
InputStream inputStream = new FileInputStream(file);
try {
return getAudioInputStream(inputStream, (int) file.length());
... | final FlacAudioFileReader flacAudioFileReader = new FlacAudioFileReader();
final File flacTestFile = getFlacTestFile("cymbals.flac");
InputStream in = null;
try {
in = new FileInputStream(flacTestFile);
assertFalse("For this test the stream MUST NOT support mark(... |
2017533_3 | class FlacAudioFileReader extends AudioFileReader {
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
InputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
return getAudioFileFormat(inputStream, ... | final FlacAudioFileReader flacAudioFileReader = new FlacAudioFileReader();
final File flacTestFile = getFlacTestFile("cymbals.flac");
InputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(flacTestFile));
assertTrue("For this test the strea... |
2017533_4 | class FlacAudioFileReader extends AudioFileReader {
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
InputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
return getAudioFileFormat(inputStream, ... | final FlacAudioFileReader flacAudioFileReader = new FlacAudioFileReader();
final File flacTestFile = getFlacTestFile("cymbals.flac");
InputStream in = null;
try {
in = new FileInputStream(flacTestFile);
assertFalse("For this test the stream MUST NOT support mark(... |
2017533_5 | class FlacAudioFileReader extends AudioFileReader {
public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException {
InputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
return getAudioFileFormat(inputStream, ... | final FlacAudioFileReader flacAudioFileReader = new FlacAudioFileReader();
final AudioFileFormat audioFileFormat = flacAudioFileReader.getAudioFileFormat(getFlacTestFile("cymbals.flac"));
assertNotNull(audioFileFormat);
assertEquals("flac", audioFileFormat.getType().getExtension());
... |
2017533_6 | class FlacAudioFileReader extends AudioFileReader {
public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
InputStream inputStream = new FileInputStream(file);
try {
return getAudioInputStream(inputStream, (int) file.length());
... | final FlacAudioFileReader flacAudioFileReader = new FlacAudioFileReader();
final File file = File.createTempFile("flacTest", ".wav");
final OutputStream out = new FileOutputStream(file);
out.write(new byte[2048]);
out.close();
try {
flacAudioFileReader.getAudi... |
2017533_7 | class FlacAudioFileReader extends AudioFileReader {
public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException {
InputStream inputStream = new FileInputStream(file);
try {
return getAudioInputStream(inputStream, (int) file.length());
... | final FlacAudioFileReader flacAudioFileReader = new FlacAudioFileReader();
final File file = File.createTempFile("flacTest", ".wav");
final OutputStream out = new FileOutputStream(file);
out.write(new byte[2048]);
out.close();
try {
flacAudioFileReader.getAudi... |
2193717_0 | class ConvertClassToReflectedTypeMatcher implements Converter<Class<?>, Matcher<FluentAccess<?>>> {
@Override
public Matcher<FluentAccess<?>> convert(final Class<?> from) {
return reflectingOn(from);
}
}
class TestConvertClassToReflectedTypeMatcher {
@Test
public void classConvertedToMat... | final Matcher<FluentAccess<?>> matcherUnderTest =
new ConvertClassToReflectedTypeMatcher().convert(ExampleClass.class);
assertThat(type(ExampleClass.class), matcherUnderTest);
}
} |
2193717_2 | class ConvertClassToReflectedType implements Converter<Class<?>, FluentClass<?>> {
@Override
public FluentClass<?> convert(final Class<?> from) {
return reflectedTypeFactory.reflect(from);
}
public ConvertClassToReflectedType(final ReflectedTypeFactory reflectedTypeFactory);
}
class TestCon... | assertThat(
new ConvertClassToReflectedType(new ReflectedTypeFactoryImpl()).convert(ExampleClass.class),
reflectingOn(ExampleClass.class));
}
} |
2280644_0 | class PosixFileNameComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
String o1WithoutDot = o1;
String o2WithoutDot = o2;
if (o1.indexOf(AeshConstants.DOT) == 0) {
o1WithoutDot = o1.substring(1);
}
if (o2.indexOf(... | String s1 = "abcde";
String s2 = "abcde";
assertTrue(s1 + " should equals " + s2, posixComparator.compare(s1, s2) == 0);
}
} |
2280644_1 | class PosixFileNameComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
String o1WithoutDot = o1;
String o2WithoutDot = o2;
if (o1.indexOf(AeshConstants.DOT) == 0) {
o1WithoutDot = o1.substring(1);
}
if (o2.indexOf(... | String s1 = "Abcde";
String s2 = "Bbcde";
assertTrue(s1 + " should be before " + s2, posixComparator.compare(s1, s2) < 0);
String s3 = "abcde";
String s4 = "Bbcde";
assertTrue(s3 + " should be before " + s4, posixComparator.compare(s3, s4) < 0);
String s5 = "b... |
2280644_2 | class PosixFileNameComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
String o1WithoutDot = o1;
String o2WithoutDot = o2;
if (o1.indexOf(AeshConstants.DOT) == 0) {
o1WithoutDot = o1.substring(1);
}
if (o2.indexOf(... | String s1 = "abcde";
String s2 = "Abc";
assertTrue(s1 + " should be after " + s2, posixComparator.compare(s1, s2) > 0);
String s3 = "Abcde";
String s4 = "abc";
assertTrue(s3 + " should be after " + s4, posixComparator.compare(s3, s4) > 0);
}
} |
2280644_3 | class PosixFileNameComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
String o1WithoutDot = o1;
String o2WithoutDot = o2;
if (o1.indexOf(AeshConstants.DOT) == 0) {
o1WithoutDot = o1.substring(1);
}
if (o2.indexOf(... | String s1 = ".Abcde";
String s2 = "Bbcde";
assertTrue(s1 + " should be before " + s2, posixComparator.compare(s1, s2) < 0);
String s3 = "Abcde";
String s4 = ".Bbcde";
assertTrue(s3 + " should be before " + s4, posixComparator.compare(s3, s4) < 0);
}
} |
2280644_4 | class PosixFileNameComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
String o1WithoutDot = o1;
String o2WithoutDot = o2;
if (o1.indexOf(AeshConstants.DOT) == 0) {
o1WithoutDot = o1.substring(1);
}
if (o2.indexOf(... | String s1 = "abcde";
String s2 = "Abcde";
assertTrue(s1 + " should be before " + s2, posixComparator.compare(s1, s2) < 0);
String s3 = "AbCde";
String s4 = "Abcde";
assertTrue(s3 + " should be after " + s4, posixComparator.compare(s3, s4) > 0);
}
} |
2280644_5 | class PosixFileNameComparator implements Comparator<String> {
@Override
public int compare(String o1, String o2) {
String o1WithoutDot = o1;
String o2WithoutDot = o2;
if (o1.indexOf(AeshConstants.DOT) == 0) {
o1WithoutDot = o1.substring(1);
}
if (o2.indexOf(... | String s1 = ".abcde";
String s2 = "abcde";
assertTrue(s1 + " should be after " + s2, posixComparator.compare(s1, s2) > 0);
String s3 = "abcde";
String s4 = ".abcde";
assertTrue(s3 + " should be before " + s4, posixComparator.compare(s3, s4) < 0);
}
} |
2280644_6 | class GraalReflectionFileGenerator {
public void generateReflection(CommandLineParser<CommandInvocation> parser, Writer w) throws IOException {
w.append('[').append(getLineSeparator());
processCommand(parser, w);
appendOptions(w);
w.append(getLineSeparator()).append("]");
}
... |
GraalReflectionFileGenerator generator = new GraalReflectionFileGenerator();
CommandLineParser<CommandInvocation> parser = getParser(TestCommand1.class);
StringWriter writer = new StringWriter();
generator.generateReflection(parser, writer);
assertEquals(readFile("src/test/reso... |
2280644_7 | class GraalReflectionFileGenerator {
public void generateReflection(CommandLineParser<CommandInvocation> parser, Writer w) throws IOException {
w.append('[').append(getLineSeparator());
processCommand(parser, w);
appendOptions(w);
w.append(getLineSeparator()).append("]");
}
... |
GraalReflectionFileGenerator generator = new GraalReflectionFileGenerator();
CommandLineParser<CommandInvocation> parser = getParser(TestCommand2.class);
StringWriter writer = new StringWriter();
generator.generateReflection(parser, writer);
assertEquals(readFile("src/test/reso... |
2280644_8 | class GraalReflectionFileGenerator {
public void generateReflection(CommandLineParser<CommandInvocation> parser, Writer w) throws IOException {
w.append('[').append(getLineSeparator());
processCommand(parser, w);
appendOptions(w);
w.append(getLineSeparator()).append("]");
}
... |
GraalReflectionFileGenerator generator = new GraalReflectionFileGenerator();
CommandLineParser<CommandInvocation> parser = getParser(TestCommand3.class);
StringWriter writer = new StringWriter();
generator.generateReflection(parser, writer);
assertEquals(readFile("src/test/reso... |
2827764_0 | class App {
public String getMessage() {
return message;
}
public App();
public App(String message);
public static void main(String[] args);
public void setMessage(String message);
public void run();
protected void readMessageFromFile(String file);
private static final Logger LOG;
private App app;
}
... | String message = app.getMessage();
assertEquals("Hello, world!", message);
LOG.debug(message);
}
} |
3052688_0 | class DateUtils {
public static Date yearStart() {
final GregorianCalendar calendar = new GregorianCalendar(US);
calendar.set(DAY_OF_YEAR, 1);
return calendar.getTime();
}
public static Date today();
public static Date yesterday();
public static Date addDays(final int days, final Calendar from);... | Date date = DateUtils.yearStart();
assertNotNull(date);
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
assertEquals(1, calendar.get(DAY_OF_YEAR));
}
} |
3052688_1 | class DateUtils {
public static Date yearEnd() {
final GregorianCalendar calendar = new GregorianCalendar(US);
calendar.add(YEAR, 1);
calendar.set(DAY_OF_YEAR, 1);
calendar.add(DAY_OF_YEAR, -1);
return calendar.getTime();
}
public static Date today();
public static Date yesterday();
publ... | Date date = DateUtils.yearEnd();
assertNotNull(date);
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(date);
assertEquals(11, calendar.get(MONTH));
assertEquals(31, calendar.get(DAY_OF_MONTH));
}
} |
4269155_0 | class EnvironmentScopeExtractor implements AttributeExtractor {
@Override
public void removeValue(String name) {
request.setVariable(name, null);
}
public EnvironmentScopeExtractor(Environment request);
@SuppressWarnings("unchecked") @Override public Enumeration<String> getKeys();
@O... | Template template = createMock(Template.class);
TemplateHashModel model = createMock(TemplateHashModel.class);
TemplateModel valueModel = createMock(TemplateModel.class);
Configuration configuration = createMock(Configuration.class);
Writer writer = new StringWriter();
e... |
4269155_1 | class EnvironmentScopeExtractor implements AttributeExtractor {
@SuppressWarnings("unchecked")
@Override
public Enumeration<String> getKeys() {
try {
return Collections.<String> enumeration(request.getKnownVariableNames());
} catch (TemplateModelException e) {
throw ... | Template template = createMock(Template.class);
TemplateHashModel model = createMock(TemplateHashModel.class);
TemplateModel valueModel = createMock(TemplateModel.class);
Configuration configuration = createMock(Configuration.class);
Set<String> names = new HashSet<String>();
... |
4269155_2 | class EnvironmentScopeExtractor implements AttributeExtractor {
@SuppressWarnings("unchecked")
@Override
public Enumeration<String> getKeys() {
try {
return Collections.<String> enumeration(request.getKnownVariableNames());
} catch (TemplateModelException e) {
throw ... | Template template = createMock(Template.class);
TemplateHashModelEx model = createMock(TemplateHashModelEx.class);
TemplateModel valueModel = createMock(TemplateModel.class);
Configuration configuration = createMock(Configuration.class);
Set<String> names = createMock(Set.class);... |
4269155_3 | class EnvironmentScopeExtractor implements AttributeExtractor {
@Override
public Object getValue(String key) {
try {
TemplateModel variable = request.getVariable(key);
if (variable != null) {
return DeepUnwrap.unwrap(variable);
}
return nu... | Template template = createMock(Template.class);
TemplateHashModel model = createMock(TemplateHashModel.class);
TemplateScalarModel valueModel = createMock(TemplateScalarModel.class);
Configuration configuration = createMock(Configuration.class);
ObjectWrapper objectWrapper = crea... |
4269155_4 | class EnvironmentScopeExtractor implements AttributeExtractor {
@Override
public Object getValue(String key) {
try {
TemplateModel variable = request.getVariable(key);
if (variable != null) {
return DeepUnwrap.unwrap(variable);
}
return nu... | Template template = createMock(Template.class);
TemplateHashModel model = createMock(TemplateHashModel.class);
TemplateScalarModel valueModel = createMock(TemplateScalarModel.class);
Configuration configuration = createMock(Configuration.class);
ObjectWrapper objectWrapper = crea... |
4269155_5 | class EnvironmentScopeExtractor implements AttributeExtractor {
@Override
public Object getValue(String key) {
try {
TemplateModel variable = request.getVariable(key);
if (variable != null) {
return DeepUnwrap.unwrap(variable);
}
return nu... | Template template = createMock(Template.class);
TemplateHashModel model = createMock(TemplateHashModel.class);
TemplateScalarModel valueModel = createMock(TemplateScalarModel.class);
Configuration configuration = createMock(Configuration.class);
ObjectWrapper objectWrapper = crea... |
4269155_6 | class EnvironmentScopeExtractor implements AttributeExtractor {
@Override
public void setValue(String key, Object value) {
try {
TemplateModel model = request.getObjectWrapper().wrap(value);
request.setVariable(key, model);
} catch (TemplateModelException e) {
... | Template template = createMock(Template.class);
TemplateHashModel model = createMock(TemplateHashModel.class);
TemplateModel valueModel = createMock(TemplateModel.class);
Configuration configuration = createMock(Configuration.class);
ObjectWrapper objectWrapper = createMock(Objec... |
4269155_7 | class EnvironmentScopeExtractor implements AttributeExtractor {
@Override
public void setValue(String key, Object value) {
try {
TemplateModel model = request.getObjectWrapper().wrap(value);
request.setVariable(key, model);
} catch (TemplateModelException e) {
... | Template template = createMock(Template.class);
TemplateHashModel model = createMock(TemplateHashModel.class);
TemplateModel valueModel = createMock(TemplateModel.class);
Configuration configuration = createMock(Configuration.class);
ObjectWrapper objectWrapper = createMock(Objec... |
5155211_3 | class SensorDataSource {
public void addSensorDataSink(SensorDataSink sink) {
addSensorDataSink(sink, 1.0);
}
public SensorDataSource();
public SensorDataSource(SensorDataSink sink);
public synchronized void addSensorDataSink(SensorDataSink sink, double weight);
public synchronized void removeSensorDataSin... | SensorDataSink ds0 = new SensorDataSink() {
@Override
public void onSensorData(long timestamp, Object value) {
}
};
SensorDataSink ds1 = new SensorDataSink() {
@Override
public void onSensorData(long timestamp, Object value) {
}
};
SensorDataSink ds2 = new SensorDataS... |
5155211_5 | class ParameterService {
public synchronized void setParam(Parameter param, Object value) {
// check either param is registered
if (getParam(param.getId()) != param) {
throw new IllegalArgumentException(String.format("parameter provided with id %s is not the same as the registered one"));
}
try {
... | assertEquals(.5f, (Float)f.getDefaultValue(), 0);
ps.setParam("float", "0.7");
assertEquals(.7f, (Float)f.getValue(), 0);
ps.setParam(f, 0.8f);
assertEquals(.8f, (Float)f.getValue(), 0);
}
} |
5155211_6 | class ParameterService {
public synchronized void setParam(Parameter param, Object value) {
// check either param is registered
if (getParam(param.getId()) != param) {
throw new IllegalArgumentException(String.format("parameter provided with id %s is not the same as the registered one"));
}
try {
... | ps.setParam("int", "7");
assertEquals(7, intVal);
ps.setParam("int", "8");
assertEquals(8, intVal);
}
} |
5518934_1 | class GlacierUploaderOptionParser extends OptionParser {
public String parseEndpointToRegion(String endpointOptionValue) {
String region = endpointOptionValue;
final Matcher matcher = REGION_REGEX_PATTERN.matcher(endpointOptionValue);
if(matcher.matches()) {
region = matcher.gr... | assertEquals("eu-west-1", optionsParser.parseEndpointToRegion(ENDPOINT_URL));
assertEquals("eu-central-2", optionsParser.parseEndpointToRegion("eu-central-2"));
}
} |
5518934_2 | class GlacierUploaderOptionParser extends OptionParser {
public List<File> mergeNonOptionsFiles(List<File> optionsFiles, List<String> nonOptions) {
final List<File> files = new ArrayList<>(optionsFiles);
if (!nonOptions.isEmpty()) {
// Adds non options to the list in order
... | File tempFile = File.createTempFile("this is a test with whitespaces", ".txt");
tempFile.deleteOnExit();
System.out.println("Using temp file: " + tempFile.getAbsolutePath());
// use a dummy configuration
final CompositeConfiguration dummyConfig = new CompositeConfiguration();
... |
5518934_3 | class VaultInventoryPrinter {
public String printArchiveSize(final JSONObject archive) throws JSONException {
final BigDecimal size = archive.getBigDecimal("Size");
final String humanReadableSize = HumanReadableSize.parse(size);
return size + " (" + humanReadableSize + ")";
}
publi... | final JSONObject inventoryJson = new JSONObject("{\"Size\": 73476694570 }");
final VaultInventoryPrinter printer = new VaultInventoryPrinter();
final String readableSize = printer.printArchiveSize(inventoryJson);
assertEquals("73476694570 (68.44GB)", readableSize);
}
} |
5518934_4 | class JobPrinter {
public void printJob(GlacierJobDescription job, OutputStream o) {
final PrintWriter out = new PrintWriter(o);
out.println("Job ID:\t\t\t\t" + job.getJobId());
out.println("Creation date:\t\t\t" + job.getCreationDate());
if (job.getCompleted()) {
out.pr... | final String jobId = UUID.randomUUID().toString();
final String statusMessage = UUID.randomUUID().toString();
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final GlacierJobDescription job = new GlacierJobDescription();
job.setJobId(jobId);
job.setComplet... |
5518934_5 | class VaultPrinter {
public void printVault(final DescribeVaultOutput output, OutputStream o) {
final PrintWriter out = new PrintWriter(o);
final String creationDate = output.getCreationDate();
final String lastInventoryDate = output.getLastInventoryDate();
final Long numberOfArchiv... | final String linebreak = System.getProperty("line.separator");
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final DescribeVaultOutput describeVaultResult = new DescribeVaultOutput();
describeVaultResult.setCreationDate(CREATION_DATE);
describeVaultResult.setLast... |
5518934_6 | class VaultPrinter {
public void printVault(final DescribeVaultOutput output, OutputStream o) {
final PrintWriter out = new PrintWriter(o);
final String creationDate = output.getCreationDate();
final String lastInventoryDate = output.getLastInventoryDate();
final Long numberOfArchiv... | final String linebreak = System.getProperty("line.separator");
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final DescribeVaultResult describeVaultResult = new DescribeVaultResult();
describeVaultResult.setCreationDate(CREATION_DATE);
describeVaultResult.setLast... |
5518934_7 | class HumanReadableSize {
public static String[] sanitize(final String size) {
LOG.debug("Sanitizing '{}'", size);
final Pattern patternClass = Pattern.compile("([0-9.]+)\\s*?([kMGTP]?B)");
final Matcher m = patternClass.matcher(size);
String[] s = new String[]{size, "B"};
i... | assertArrayEquals(new String[]{"123456789", "B"}, HumanReadableSize.sanitize("123456789"));
}
} |
5518934_8 | class HumanReadableSize {
public static String[] sanitize(final String size) {
LOG.debug("Sanitizing '{}'", size);
final Pattern patternClass = Pattern.compile("([0-9.]+)\\s*?([kMGTP]?B)");
final Matcher m = patternClass.matcher(size);
String[] s = new String[]{size, "B"};
i... | assertArrayEquals(new String[]{"123456789", "B"}, HumanReadableSize.sanitize("123456789 B"));
}
} |
5518934_9 | class HumanReadableSize {
public static String[] sanitize(final String size) {
LOG.debug("Sanitizing '{}'", size);
final Pattern patternClass = Pattern.compile("([0-9.]+)\\s*?([kMGTP]?B)");
final Matcher m = patternClass.matcher(size);
String[] s = new String[]{size, "B"};
i... | assertArrayEquals(new String[]{"123456789", "kB"}, HumanReadableSize.sanitize("123456789kB"));
}
} |
7292204_0 | class Util {
public static <T> List<T> reverse(List<T> src) {
List<T> copy = new ArrayList<T>(src);
Collections.reverse(copy);
return copy;
}
private Util();
@SuppressWarnings("unchecked") public static T[] reverse(T[] array);
public static String expandUserHome(String te... | Integer[] i = {1, 2, 3, 4, 5};
Integer[] result = Util.reverse(i);
assertTrue(Arrays.equals(new Integer[] {1, 2, 3, 4, 5}, i));
assertTrue(Arrays.equals(new Integer[] {5, 4, 3, 2, 1}, result));
}
} |
7292204_4 | class Util {
public static String expandUserHome(String text) {
if (text.equals("~"))
return getUserHome();
if (text.indexOf("~/") == 0 || text.indexOf("file:~/") == 0 || text.indexOf("jar:file:~/") == 0)
return text.replaceFirst("~/", Matcher.quoteReplacement(getUserHome())... | SystemProvider save = UtilTest.setSystem(new SystemProviderForTest(
new Properties() {{
setProperty("user.home", "/home/john");
}}, new HashMap<String, String>()
));
try {
assertEquals("/home/john", Util.expandUserHome("~"));
... |
7292204_5 | class Util {
public static String expandUserHome(String text) {
if (text.equals("~"))
return getUserHome();
if (text.indexOf("~/") == 0 || text.indexOf("file:~/") == 0 || text.indexOf("jar:file:~/") == 0)
return text.replaceFirst("~/", Matcher.quoteReplacement(getUserHome())... | SystemProvider save = UtilTest.setSystem(new SystemProviderForTest(
new Properties() {{
setProperty("user.home", "C:\\Users\\John");
}}, new HashMap<String, String>()
));
try {
assertEquals("C:\\Users\\John", Util.expandUserHome("~"... |
7292204_6 | class Base64 {
public static String encode(byte[] data) {
if (encoderMethod == null) throw new UnsupportedOperationException("Cannot find Base64 encoder.");
try {
return (String) encoderMethod.invoke(encoderObject, data);
} catch (Exception e) {
throw new Unsupported... | String input = "Hello World!";
String result = Base64.encode(input.getBytes());
assertEquals("SGVsbG8gV29ybGQh", result);
}
} |
7292204_7 | class Base64 {
public static byte[] decode(String data) {
if (decoderMethod == null) throw new UnsupportedOperationException("Cannot find Base64 decoder.");
try {
return (byte[]) decoderMethod.invoke(decoderObject, data);
} catch (Exception e) {
throw new Unsupported... | String input = "SGVsbG8gV29ybGQh";
byte[] result = Base64.decode(input);
assertEquals("Hello World!", new String(result));
}
} |
7292204_8 | class Reflection {
public static boolean isClassAvailable(String className) {
return forName(className) != null;
}
private Reflection();
public static Class<?> forName(String className);
private static Java8Support getJava8Support();
private static Java8Support java8NotSupported();
... | boolean available = Reflection.isClassAvailable("foo.bar.baz.FooBar");
assertFalse(available);
}
} |
7292204_9 | class Reflection {
public static boolean isClassAvailable(String className) {
return forName(className) != null;
}
private Reflection();
public static Class<?> forName(String className);
private static Java8Support getJava8Support();
private static Java8Support java8NotSupported();
... | boolean available = Reflection.isClassAvailable("java.lang.String");
assertTrue(available);
}
} |
8103494_1 | class TeamCityRestRequest {
public Build fetchBuildStatus(int buildId) throws IOException {
String urlEndpoint = buildServerUrl + PATH_BUILD + Integer.toString(buildId);
JsonElement json = RestRequest.fetchJson(username, password, urlEndpoint);
System.out.println("... | String serverUrl = "http://teamcity.gonevertical.org";
String username = github.getUsername();
String password = github.getPassword();
int buildId = 299;
TeamCityRestRequest rest = new TeamCityRestRequest(serverUrl, username, password);
Build build = rest.fetchBu... |
8103494_2 | class TeamCityRestRequest {
public Build fetchBuildStatus(int buildId) throws IOException {
String urlEndpoint = buildServerUrl + PATH_BUILD + Integer.toString(buildId);
JsonElement json = RestRequest.fetchJson(username, password, urlEndpoint);
System.out.println("... | String serverUrl = "http://teamcity.gonevertical.org";
String username = github.getUsername();
String password = github.getPassword();
int buildId = 490;
TeamCityRestRequest rest = new TeamCityRestRequest(serverUrl, username, password);
Build build = rest.fetchBu... |
8103494_7 | class PullNotification {
public static void main(String[] args) {
PullNotification.newInstance(args).run();
}
private PullNotification();
private PullNotification(String[] args);
private static PullNotification newInstance(String[] args);
private void parameterParser(String[] args);... | String[] args = new String[8];
args[0] = "-ro=branflake2267";
args[1] = "-rn=Sandbox";
args[2] = "-sha=2e84e6446df300cd572930869c5ed2be8ee1f614";
args[3] = "-github=github";
args[4] = "-teamcity=teamcity-gonevertical";
args[5] = "-returnurl=http://teamcity.gonever... |
8121707_0 | class TypeParameter {
@Override
public String toString() {
return new TypeParameterRenderer().render(this, null);
}
public TypeParameter(String name);
public TypeParameter(String name, List<FullyQualifiedJavaType> extendsTypes);
public String getName();
public List<FullyQualifie... |
FullyQualifiedJavaType list = FullyQualifiedJavaType.getNewListInstance();
FullyQualifiedJavaType compare = new FullyQualifiedJavaType("java.util.Comparator");
TypeParameter typeParameter = new TypeParameter("T", Arrays.asList(list, compare));
assertNotNull(typeParameter);
asse... |
8121707_1 | class Interface extends InnerInterface implements CompilationUnit {
@Override
public void addImportedType(FullyQualifiedJavaType importedType) {
if (importedType.isExplicitlyImported()
&& !importedType.getPackageName().equals(getType().getPackageName())) {
importedTypes.add(... |
Interface interfaze = new Interface("com.foo.UserInterface");
FullyQualifiedJavaType arrayList = FullyQualifiedJavaType.getNewArrayListInstance();
interfaze.addImportedType(arrayList);
assertNotNull(interfaze.getImportedTypes());
assertEquals(1, interfaze.getImportedTypes().siz... |
8121707_2 | class Interface extends InnerInterface implements CompilationUnit {
@Override
public void addImportedTypes(Set<FullyQualifiedJavaType> importedTypes) {
this.importedTypes.addAll(importedTypes);
}
public Interface(FullyQualifiedJavaType type);
public Interface(String type);
@Override... |
Interface interfaze = new Interface("com.foo.UserInterface");
Set<FullyQualifiedJavaType> importedTypes = new HashSet<>();
FullyQualifiedJavaType arrayList = FullyQualifiedJavaType.getNewArrayListInstance();
FullyQualifiedJavaType hashMap = FullyQualifiedJavaType.getNewHashMapInstance(... |
8121707_3 | class Interface extends InnerInterface implements CompilationUnit {
@Override
public void addFileCommentLine(String commentLine) {
fileCommentLines.add(commentLine);
}
public Interface(FullyQualifiedJavaType type);
public Interface(String type);
@Override public Set<FullyQualifiedJa... |
Interface interfaze = new Interface("com.foo.UserInterface");
interfaze.addFileCommentLine("test");
assertNotNull(interfaze.getFileCommentLines());
assertEquals(1, interfaze.getFileCommentLines().size());
assertEquals("test", interfaze.getFileCommentLines().get(0));
}
} |
8121707_4 | class Interface extends InnerInterface implements CompilationUnit {
@Override
public void addStaticImport(String staticImport) {
staticImports.add(staticImport);
}
public Interface(FullyQualifiedJavaType type);
public Interface(String type);
@Override public Set<FullyQualifiedJavaTy... |
Interface interfaze = new Interface("com.foo.UserInterface");
interfaze.addStaticImport("com.foo.StaticUtil");
assertNotNull(interfaze.getStaticImports());
assertEquals(1, interfaze.getStaticImports().size());
assertTrue(interfaze.getStaticImports().contains("com.foo.StaticUtil... |
8121707_5 | class Interface extends InnerInterface implements CompilationUnit {
@Override
public void addStaticImports(Set<String> staticImports) {
this.staticImports.addAll(staticImports);
}
public Interface(FullyQualifiedJavaType type);
public Interface(String type);
@Override public Set<Full... |
Interface interfaze = new Interface("com.foo.UserInterface");
Set<String> staticImports = new HashSet<>();
staticImports.add("com.foo.StaticUtil1");
staticImports.add("com.foo.StaticUtil2");
interfaze.addStaticImports(staticImports);
assertNotNull(interfaze.getStaticImp... |
8121707_6 | class InnerClass extends AbstractJavaType {
public void setSuperClass(FullyQualifiedJavaType superClass) {
this.superClass = superClass;
}
public InnerClass(FullyQualifiedJavaType type);
public InnerClass(String type);
public Optional<FullyQualifiedJavaType> getSuperClass();
public ... | InnerClass clazz = new InnerClass("com.foo.UserClass");
assertFalse(clazz.getSuperClass().isPresent());
clazz.setSuperClass("com.hoge.SuperClass");
assertNotNull(clazz.getSuperClass());
assertEquals("com.hoge.SuperClass", clazz.getSuperClass().get().getFullyQualifiedName());
... |
8121707_7 | class InnerClass extends AbstractJavaType {
public void addTypeParameter(TypeParameter typeParameter) {
this.typeParameters.add(typeParameter);
}
public InnerClass(FullyQualifiedJavaType type);
public InnerClass(String type);
public Optional<FullyQualifiedJavaType> getSuperClass();
... | InnerClass clazz = new InnerClass("com.foo.UserClass");
assertEquals(0, clazz.getTypeParameters().size());
clazz.addTypeParameter(new TypeParameter("T"));
assertEquals(1, clazz.getTypeParameters().size());
clazz.addTypeParameter(new TypeParameter("U"));
assertEquals(2, c... |
8121707_8 | class InnerClass extends AbstractJavaType {
public void addInitializationBlock(InitializationBlock initializationBlock) {
initializationBlocks.add(initializationBlock);
}
public InnerClass(FullyQualifiedJavaType type);
public InnerClass(String type);
public Optional<FullyQualifiedJavaTy... | InnerClass clazz = new InnerClass("com.foo.UserClass");
assertEquals(0, clazz.getInitializationBlocks().size());
clazz.addInitializationBlock(new InitializationBlock(false));
assertEquals(1, clazz.getInitializationBlocks().size());
clazz.addInitializationBlock(new Initialization... |
8121707_9 | class InnerClass extends AbstractJavaType {
public void setAbstract(boolean isAbtract) {
this.isAbstract = isAbtract;
}
public InnerClass(FullyQualifiedJavaType type);
public InnerClass(String type);
public Optional<FullyQualifiedJavaType> getSuperClass();
public void setSuperClass(... | InnerClass clazz = new InnerClass("com.foo.UserClass");
assertFalse(clazz.isAbstract());
clazz.setAbstract(true);
assertTrue(clazz.isAbstract());
}
} |
854893_28 | class OutputStreamBitChannel implements BitChannel, Closeable {
public void write(boolean value) throws IOException {
if (value) {
buffer = (byte) (0xff & ((buffer << 1) | 0x01));
} else {
buffer = (byte) (0xff & (buffer << 1));
}
if (++bitPos == 8) {
... | OutputStreamBitChannel channel = new OutputStreamBitChannel(out);
channel.write(true);
channel.write(true);
channel.write(true);
channel.write(true);
channel.write(false);
channel.write(false);
channel.write(false);
channel.write(false);
ch... |
854893_29 | class OutputStreamBitChannel implements BitChannel, Closeable {
public void write(boolean value) throws IOException {
if (value) {
buffer = (byte) (0xff & ((buffer << 1) | 0x01));
} else {
buffer = (byte) (0xff & (buffer << 1));
}
if (++bitPos == 8) {
... | OutputStreamBitChannel channel = new OutputStreamBitChannel(out);
channel.write(8, (byte) 32);
verify(out).write((byte) 32);
verifyNoMoreInteractions(out);
}
} |
854893_30 | class OutputStreamBitChannel implements BitChannel, Closeable {
public void write(boolean value) throws IOException {
if (value) {
buffer = (byte) (0xff & ((buffer << 1) | 0x01));
} else {
buffer = (byte) (0xff & (buffer << 1));
}
if (++bitPos == 8) {
... | OutputStreamBitChannel channel = new OutputStreamBitChannel(out);
channel.write(4, (byte) 0xff); // 1111
channel.write(4, (byte) 0x00); // 0000
verify(out).write((byte) 0xf0);
verifyNoMoreInteractions(out);
}
} |
854893_31 | class OutputStreamBitChannel implements BitChannel, Closeable {
public void write(boolean value) throws IOException {
if (value) {
buffer = (byte) (0xff & ((buffer << 1) | 0x01));
} else {
buffer = (byte) (0xff & (buffer << 1));
}
if (++bitPos == 8) {
... | OutputStreamBitChannel channel = new OutputStreamBitChannel(out);
channel.write(3, (byte) 0xff); // 111
channel.write(7, (byte) 0x00); // 0000000
verify(out).write((byte) Integer.parseInt("11100000", 2));
verifyNoMoreInteractions(out);
}
} |
854893_32 | class OutputStreamBitChannel implements BitChannel, Closeable {
public void write(boolean value) throws IOException {
if (value) {
buffer = (byte) (0xff & ((buffer << 1) | 0x01));
} else {
buffer = (byte) (0xff & (buffer << 1));
}
if (++bitPos == 8) {
... | OutputStreamBitChannel channel = new OutputStreamBitChannel(out);
channel.write(3, (byte) 0xff); // 111
channel.write(7, (byte) 0x00); // 0000000
channel.write(8, (byte) 0xff); // 11111111
channel.write(6, (byte) 0x00); // 000000
verify(out).write((byte) Integer.parseInt(... |
854893_33 | class OutputStreamBitChannel implements BitChannel, Closeable {
public void write(boolean value) throws IOException {
if (value) {
buffer = (byte) (0xff & ((buffer << 1) | 0x01));
} else {
buffer = (byte) (0xff & (buffer << 1));
}
if (++bitPos == 8) {
... | OutputStreamBitChannel channel = new OutputStreamBitChannel(out);
channel.write(12, (int) 0xfff, ByteOrder.BigEndian); // 1111 1111 1111
channel.write(4, (int) 0x0, ByteOrder.BigEndian); // 0000
verify(out).write((byte) Integer.parseInt("11111111", 2));
verify(out).write((byte) I... |
854893_34 | class OutputStreamBitChannel implements BitChannel, Closeable {
public void write(boolean value) throws IOException {
if (value) {
buffer = (byte) (0xff & ((buffer << 1) | 0x01));
} else {
buffer = (byte) (0xff & (buffer << 1));
}
if (++bitPos == 8) {
... | OutputStreamBitChannel channel = new OutputStreamBitChannel(out);
channel.write(12, (int) 0xfff, ByteOrder.BigEndian); // 1111 1111 1111
channel.write(5, (byte) 0x0); // 0000 0
verify(out).write((byte) Integer.parseInt("11111111", 2));
verify(out).write((byte) Integer.parseInt("1... |
854893_35 | class OutputStreamBitChannel implements BitChannel, Closeable {
public void write(boolean value) throws IOException {
if (value) {
buffer = (byte) (0xff & ((buffer << 1) | 0x01));
} else {
buffer = (byte) (0xff & (buffer << 1));
}
if (++bitPos == 8) {
... | OutputStreamBitChannel channel = new OutputStreamBitChannel(out);
channel.write(12, (int) 0xf00, ByteOrder.LittleEndian); // 1111 0000 0000
channel.write(4, (int) 0x0, ByteOrder.LittleEndian); // 0000
// What I expect:
// 0000 0000 1111 0000
verify(out).write((byte) Inte... |
854893_36 | class OutputStreamBitChannel implements BitChannel, Closeable {
public void write(boolean value) throws IOException {
if (value) {
buffer = (byte) (0xff & ((buffer << 1) | 0x01));
} else {
buffer = (byte) (0xff & (buffer << 1));
}
if (++bitPos == 8) {
... | OutputStreamBitChannel channel = new OutputStreamBitChannel(out);
channel.write(12, Long.MAX_VALUE / 2, ByteOrder.BigEndian); // 1111 1111 1111
channel.write(5, (byte) 0x0); // 0000 0
verify(out).write((byte) Integer.parseInt("11111111", 2));
verify(out).write((byte) Integer.pars... |
854893_37 | class BoundedBitChannel implements BitChannel {
public void write(boolean value) throws IOException {
if (written + 1 <= maxBits) {
channel.write(value);
written += 1;
} else {
throw new IOException(OVERRUN_MESSAGE);
}
}
public BoundedBitChannel... | boundedChannel.write(9, Integer.MAX_VALUE, ByteOrder.BigEndian);
verify(channel).write(9, Integer.MAX_VALUE, ByteOrder.BigEndian);
verifyNoMoreInteractions(channel);
}
} |
854893_39 | class BoundedBitChannel implements BitChannel {
public void write(boolean value) throws IOException {
if (written + 1 <= maxBits) {
channel.write(value);
written += 1;
} else {
throw new IOException(OVERRUN_MESSAGE);
}
}
public BoundedBitChannel... | boundedChannel.write(9, Long.MAX_VALUE, ByteOrder.BigEndian);
verify(channel).write(9, Long.MAX_VALUE, ByteOrder.BigEndian);
verifyNoMoreInteractions(channel);
}
} |
854893_41 | class BoundedBitChannel implements BitChannel {
public void write(boolean value) throws IOException {
if (written + 1 <= maxBits) {
channel.write(value);
written += 1;
} else {
throw new IOException(OVERRUN_MESSAGE);
}
}
public BoundedBitChannel... | boundedChannel.write(9, Short.MAX_VALUE, ByteOrder.BigEndian);
verify(channel).write(9, Short.MAX_VALUE, ByteOrder.BigEndian);
verifyNoMoreInteractions(channel);
}
} |
854893_43 | class BoundedBitChannel implements BitChannel {
public void write(boolean value) throws IOException {
if (written + 1 <= maxBits) {
channel.write(value);
written += 1;
} else {
throw new IOException(OVERRUN_MESSAGE);
}
}
public BoundedBitChannel... | boundedChannel.write(8, Byte.MAX_VALUE, ByteOrder.BigEndian);
boundedChannel.write(1, Byte.MAX_VALUE, ByteOrder.BigEndian);
verify(channel).write(8, Byte.MAX_VALUE, ByteOrder.BigEndian);
verify(channel).write(1, Byte.MAX_VALUE, ByteOrder.BigEndian);
verifyNoMoreInteractions(chann... |
854893_45 | class BoundedBitChannel implements BitChannel {
public void close() throws IOException {
channel.close();
}
public BoundedBitChannel(@Nonnull BitChannel channel, @Nonnegative long maxBits);
public void write(boolean value);
public void write(int nrbits, byte value);
public void write... | boundedChannel.close();
verify(channel).close();
}
} |
854893_46 | class BoundedBitChannel implements BitChannel {
public int getRelativeBitPos() {
return channel.getRelativeBitPos();
}
public BoundedBitChannel(@Nonnull BitChannel channel, @Nonnegative long maxBits);
public void write(boolean value);
public void write(int nrbits, byte value);
public... | when(channel.getRelativeBitPos()).thenReturn(4);
assertThat(boundedChannel.getRelativeBitPos(), is(4));
verify(channel).getRelativeBitPos();
}
} |
9198697_0 | class CommandInvocation {
public String[] args() {
return Arrays.copyOf(args, args.length);
}
public CommandInvocation(final String command, final String... args);
public String command();
}
class CommandInvocationTest {
@Test
public void testArgsImmutability() throws Exception {
| final CommandInvocation commandInvocation = new CommandInvocation("cmd", "a", "t");
commandInvocation.args()[1] = "b";
assertArrayEquals(new String[] { "a", "t" }, commandInvocation.args());
}
} |
9198697_1 | class Call {
@Override
public boolean equals(final Object o) {
return
o instanceof Call && commandName.equals(((Call) o).commandName);
}
public Call(final String commandName, final Completer... completers);
public static Call call(final String commandName, final Completer... ... | final Call call = call("cmd");
assertTrue(call.equals(call("cmd")));
}
} |
9198697_2 | class Call {
@Override
public int hashCode() {
return commandName.hashCode();
}
public Call(final String commandName, final Completer... completers);
public static Call call(final String commandName, final Completer... completers);
public String commandName();
public Completer[] ... | final Call call = call("cmd");
assertTrue(call.equals(call("cmd")));
assertTrue(call.hashCode() == call("cmd").hashCode());
}
} |
9198697_3 | class HadoopREPL extends REPL {
@Override
protected void evaluate(final String input) throws ExitSignal {
popHistory();
final Iterable<String> inputParts = ARG_SPLITTER.limit(2).split(input);
if (Iterables.isEmpty(inputParts)) {
// Do nothing
} else {
fi... | final Configuration configuration = mock(Configuration.class);
final SessionState sessionState = mock(SessionState.class);
final HadoopREPL repl = new HadoopREPL(configuration, sessionState, ImmutableMap.<Call, Command>of(
call("test"), new Command() {
@Override
... |
9198697_4 | class HadoopREPL extends REPL {
@Override
protected void evaluate(final String input) throws ExitSignal {
popHistory();
final Iterable<String> inputParts = ARG_SPLITTER.limit(2).split(input);
if (Iterables.isEmpty(inputParts)) {
// Do nothing
} else {
fi... | final Configuration configuration = new Configuration();
final SessionState sessionState = mock(SessionState.class);
when(sessionState.configuration()).thenReturn(configuration);
final HadoopREPL repl = new HadoopREPL(configuration, sessionState);
doAnswer(new Answer() {
... |
9198697_5 | class HadoopREPL extends REPL {
@Override
protected void evaluate(final String input) throws ExitSignal {
popHistory();
final Iterable<String> inputParts = ARG_SPLITTER.limit(2).split(input);
if (Iterables.isEmpty(inputParts)) {
// Do nothing
} else {
fi... | final Configuration configuration = new Configuration();
final SessionState sessionState = mock(SessionState.class);
when(sessionState.configuration()).thenReturn(configuration);
final HadoopREPL repl = new HadoopREPL(configuration, sessionState);
doAnswer(new Answer() {
... |
9198697_6 | class HadoopREPL extends REPL {
@Override
protected void evaluate(final String input) throws ExitSignal {
popHistory();
final Iterable<String> inputParts = ARG_SPLITTER.limit(2).split(input);
if (Iterables.isEmpty(inputParts)) {
// Do nothing
} else {
fi... | final Configuration configuration = mock(Configuration.class);
final SessionState sessionState = mock(SessionState.class);
doAnswer(new Answer() {
@Override
public Object answer(final InvocationOnMock invocationOnMock) throws Throwable {
assertEquals("Unk... |
10585052_0 | class Stamp implements Serializable {
@Override
public boolean equals(Object o) {
if (!(o instanceof Stamp)) {
return false;
}
else {
Stamp other = (Stamp) o;
return id.equals(other.getId()) && event.equals(other.getEvent());
}
}
publ... | assertTrue(seedStamp.equals(new Stamp()));
assertFalse(seedStamp.equals(forkedStamp1));
assertTrue(forkedStamp1.equals(forkedStamp1));
assertFalse(forkedStamp1.equals(forkedStamp2));
}
} |
10585052_1 | class Stamp implements Serializable {
public Stamp[] peek() {
return new Stamp[] {
new Stamp(id, event),
new Stamp(IDs.zero(), event)
};
}
public Stamp();
Stamp(ID id, Event event);
ID getId();
Event getEvent();
public Stamp[] fork();
publi... | for (Stamp stamp : stamps) {
Stamp[] peek = stamp.peek();
assertIntEquals(2, peek.length);
assertTrue(peek[0].equals(stamp));
assertTrue(peek[1].getId().isZero());
assertTrue(peek[1].getEvent().equals(stamp.getEvent()));
assertNormalizedSt... |
10585052_2 | class Stamp implements Serializable {
public Stamp[] fork() {
ID[] ids = id.split();
return new Stamp[] {
new Stamp(ids[0], event),
new Stamp(ids[1], event)
};
}
public Stamp();
Stamp(ID id, Event event);
ID getId();
Event getEvent();
p... | for (Stamp stamp : stamps) {
Stamp[] fork = stamp.fork();
ID[] splitIDs = stamp.getId().split();
assertIntEquals(2, fork.length);
assertEquals(stamp.getEvent(), fork[0].getEvent());
assertEquals(stamp.getEvent(), fork[1].getEvent());
asser... |
10585052_3 | class Stamp implements Serializable {
public Stamp join(Stamp other) {
ID idSum = id.sum(other.id);
Event eventJoin = event.join(other.event);
return new Stamp(idSum, eventJoin);
}
public Stamp();
Stamp(ID id, Event event);
ID getId();
Event getEvent();
public... | Stamp expected = new Stamp(IDs.one(),
Events.with(1, Events.zero(), Events.with(1)));
assertEquals(expected, forkedStamp1.join(forkedStamp2));
assertEquals(expected, forkedStamp2.join(forkedStamp1));
assertNormalizedStamp(forkedStamp1.join(forkedStamp2));
}
} |
10585052_4 | class Stamp implements Serializable {
public Stamp event() {
Event filled = Filler.fill(id, event);
if (!filled.equals(event)) {
return new Stamp(id, filled);
}
else {
return new Stamp(id, Grower.grow(id, event));
}
}
public Stamp();
S... | for (Stamp stamp : stamps) {
Stamp evented = stamp.event();
assertTrue(stamp.getEvent().leq(evented.getEvent()));
assertNormalizedStamp(evented);
}
}
} |
10585052_5 | class Stamp implements Serializable {
public boolean leq(Stamp other) {
return event.leq(other.event);
}
public Stamp();
Stamp(ID id, Event event);
ID getId();
Event getEvent();
public Stamp[] fork();
public Stamp[] peek();
public Stamp join(Stamp other);
public S... | Stamp s1 = new Stamp();
Stamp s2 = new Stamp();
Assert.assertTrue(s1.leq(s2.event()));
Assert.assertTrue(Causality.lessThanEquals(s1, s2.event()));
Assert.assertFalse(s2.event().leq(s1));
Assert.assertFalse(Causality.lessThanEquals(s2.event(), s1));
}
} |
11383343_0 | class MyAction extends ActionSupport {
public String view() {
id = "11";
name = "test-11";
return SUCCESS;
}
public String getId();
public void setId(String id);
public String getName();
public void setName(String name);
public String save();
public static fina... | ActionProxy proxy = getActionProxy("/view");
// actions.MyAction myAct = (actions.MyAction) proxy.getAction();
String result = proxy.execute();
assertEquals("success", result);
// System.out.println(ToStringBuilder.reflectionToString(response));
System.out.println(response... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 14