id stringlengths 8 13 | source stringlengths 164 33.1k | target stringlengths 36 5.98k |
|---|---|---|
2280644_27 | class MapCommand implements Command<T> {
public boolean contains(String name) {
return values.containsKey(name);
}
public Object getValue(String name);
public void setValue(String name, Object value);
public void resetValue(String name);
public Map<String, Object> getValues();
publ... | TestConnection connection = new TestConnection(false);
// Build dynamic command.
DynCommand1 cmd = new DynCommand1();
DynamicOptionsProvider provider = new DynamicOptionsProvider();
MapProcessedCommandBuilder builder = MapProcessedCommandBuilder.builder();
builder.comma... |
2280644_28 | class MapCommand implements Command<T> {
public boolean contains(String name) {
return values.containsKey(name);
}
public Object getValue(String name);
public void setValue(String name, Object value);
public void resetValue(String name);
public Map<String, Object> getValues();
publ... | TestConnection connection = new TestConnection(false);
// Build dynamic command.
DynCommand1 cmd = new DynCommand1();
DynamicOptionsProvider provider = new DynamicOptionsProvider();
MapProcessedCommandBuilder builder = MapProcessedCommandBuilder.builder();
builder.comma... |
2280644_29 | class MapCommand implements Command<T> {
public boolean contains(String name) {
return values.containsKey(name);
}
public Object getValue(String name);
public void setValue(String name, Object value);
public void resetValue(String name);
public Map<String, Object> getValues();
publ... | TestConnection connection = new TestConnection(false);
// Build dynamic command.
DynCommand1 cmd = new DynCommand1();
DynamicOptionsProvider provider = new DynamicOptionsProvider();
MapProcessedCommandBuilder builder = MapProcessedCommandBuilder.builder();
builder.comma... |
2280644_30 | class ParsedLine {
public ParsedWord firstWord() {
if(words.size() > 0 )
return words.get(0);
else
return new ParsedWord("", 0);
}
public ParsedLine(String originalInput, List<ParsedWord> words,
int cursor, int cursorWord, int wordCursor,
... | List<ParsedWord> words = new ArrayList<>();
ParsedLine pl = new ParsedLine("", words, -1,
0, 0, ParserStatus.OK, "", OperatorType.NONE);
assertEquals(pl.firstWord().word(), "");
}
} |
2280644_31 | class ParsedLine {
public ParsedWord firstWord() {
if(words.size() > 0 )
return words.get(0);
else
return new ParsedWord("", 0);
}
public ParsedLine(String originalInput, List<ParsedWord> words,
int cursor, int cursorWord, int wordCursor,
... | List<ParsedWord> words = new ArrayList<>();
words.add(new ParsedWord("command", 0));
words.add(new ParsedWord("line", 1));
words.add(new ParsedWord("text", 2));
ParsedLine pl = new ParsedLine("command line text", words, -1,
0, 0, ParserStatus.OK, "", OperatorType... |
2280644_32 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
assertEquals("", lineParser.parseLine(" ", 1).selectedWord().word());
assertEquals("foo", lineParser.parseLine("foo bar", 3).selectedWord().word());
assertEquals("bar", lineParser.parseLine("foo bar", 6).selectedWord().word());
assertEqua... |
2280644_33 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
assertEquals("foo bar", lineParser.parseLine("foo\\ bar", 8).selectedWordToCursor().word());
assertEquals("foo ba", lineParser.parseLine("foo\\ bar", 7).selectedWordToCursor().word());
assertEquals("foo bar", lineParser.parseLine("ls foo\\ bar",... |
2280644_34 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
ParsedLine line = lineParser.parseLine("ls foo bar", 6);
assertEquals("foo", line.selectedWord().word());
assertFalse(line.isCursorAtEndOfSelectedWord());
assertEquals("", lineParser.parseLine(" ", 1).selectedWord().word());
li... |
2280644_35 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
assertEquals("foo bar", lineParser.parseLine("foo\\ bar", 7).selectedWord().word());
assertEquals("foo bar", lineParser.parseLine("ls foo\\ bar", 11).selectedWord().word());
}
} |
2280644_36 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
String input = "echo foo -i bar";
ParsedLine line = lineParser.parseLine(input);
assertEquals(input, line.line());
}
} |
2280644_37 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
ParsedLine line = lineParser.parseLine("foo bar \"baz 12345\" ", 19);
assertEquals("foo", line.words().get(0).word());
assertEquals(0, line.words().get(0).lineIndex());
assertEquals("bar", line.words().get(1).word());
assertEquals... |
2280644_38 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
ParsedLine line = lineParser.parseLine("\"\" \"\"");
assertEquals(" ", line.words().get(0).word());
line = lineParser.parseLine("\"\" foo bar \"\"");
assertEquals(" foo bar ", line.words().get(0).word());
line = lineParser.pa... |
2280644_39 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
ParsedLine line = lineParser.parseLine("foo bar");
ParsedLineIterator iterator = line.iterator();
int counter = 0;
while(iterator.hasNextWord()) {
if(counter == 0)
assertEquals("foo", iterator.pollWord());
... |
2280644_40 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
ParsedLine line = lineParser.parseLine("foo bar");
ParsedLineIterator iterator = line.iterator();
assertEquals("foo bar", iterator.stringFromCurrentPosition());
iterator.updateIteratorPosition(3);
assertEquals(' ', iterator.pollC... |
2280644_41 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | LineParser lineParser = new LineParser();
ParsedLine line = lineParser.parseLine("foo bar {baz 12345} ", 19, true);
assertEquals("foo", line.words().get(0).word());
assertEquals(0, line.words().get(0).lineIndex());
assertEquals("bar", line.words().get(1).word());
as... |
2280644_42 | class LineParser {
public ParsedLine parseLine(String text) {
return parseLine(text, -1);
}
public LineParser input(String text);
public LineParser cursor(int cursor);
public LineParser parseBrackets(boolean doParse);
public LineParser operators(EnumSet<OperatorType> operators);
pu... | assertEquals("mkdir", parseLine("mkdir He\\|lo").get(0).word());
assertEquals("Try to escape |", "He|lo", parseLine("mkdir He\\|lo").get(1).word());
assertEquals("Try to escape ;", "He;lo", parseLine("mkdir He\\;lo").get(1).word());
assertEquals("Try to escape \\","He\\lo", parseLine("mk... |
23330642_0 | class Main extends MainSupport {
@Override
protected Map<String, CamelContext> getCamelContextMap() {
BeanManager manager = container.getBeanManager();
return manager.getBeans(CamelContext.class, Any.Literal.INSTANCE).stream()
.map(bean -> getReference(manager, CamelContext.class, b... | Main main = new Main();
main.start();
assertThat("Camel contexts are not deployed!", main.getCamelContextMap(), allOf(hasKey("default"), hasKey("foo")));
CamelContext context = main.getCamelContextMap().get("default");
assertThat("Default Camel context is not started", context.... |
24503275_0 | class ECKey implements Serializable {
@Override
public int hashCode() {
// Public keys are random already so we can just use a part of them as the hashcode. Read from the start to
// avoid picking up the type code (compressed vs uncompressed) which is tacked on the end.
byte[] bits = ge... | assertEquals(1866897155, ECKey.fromPrivate(privateKey).hashCode());
}
} |
24503275_2 | class ECKey implements Serializable {
public boolean isPubKeyOnly() {
return priv == null;
}
public ECKey();
public ECKey(SecureRandom secureRandom);
protected ECKey(@Nullable BigInteger priv, ECPoint pub);
public static ECPoint compressPoint(ECPoint uncompressed);
public stati... | ECKey key = ECKey.fromPublicOnly(pubKey);
assertTrue(key.isPubKeyCanonical());
assertTrue(key.isPubKeyOnly());
assertArrayEquals(key.getPubKey(), pubKey);
}
} |
24503275_3 | class ECKey implements Serializable {
public static byte[] publicKeyFromPrivate(BigInteger privKey, boolean compressed) {
ECPoint point = CURVE.getG().multiply(privKey);
return point.getEncoded(compressed);
}
public ECKey();
public ECKey(SecureRandom secureRandom);
protected ECK... | byte[] pubFromPriv = ECKey.publicKeyFromPrivate(privateKey, false);
assertArrayEquals(pubKey, pubFromPriv);
}
} |
24503275_4 | class ECKey implements Serializable {
public static byte[] publicKeyFromPrivate(BigInteger privKey, boolean compressed) {
ECPoint point = CURVE.getG().multiply(privKey);
return point.getEncoded(compressed);
}
public ECKey();
public ECKey(SecureRandom secureRandom);
protected ECK... | byte[] pubFromPriv = ECKey.publicKeyFromPrivate(privateKey, true);
assertArrayEquals(compressedPubKey, pubFromPriv);
}
} |
24503275_5 | class ECKey implements Serializable {
public byte[] getAddress() {
if (pubKeyHash == null) {
byte[] pubBytes = this.pub.getEncoded(false);
pubKeyHash = HashUtil.sha3omit12(Arrays.copyOfRange(pubBytes, 1, pubBytes.length));
}
return pubKeyHash;
}
public ECKey();
... | ECKey key = ECKey.fromPublicOnly(pubKey);
assertArrayEquals(Hex.decode(address), key.getAddress());
}
} |
24503275_6 | class ECKey implements Serializable {
public String toString() {
StringBuilder b = new StringBuilder();
b.append("pub:").append(Hex.toHexString(pub.getEncoded(false)));
return b.toString();
}
public ECKey();
public ECKey(SecureRandom secureRandom);
protected ECKey(@Nulla... | ECKey key = ECKey.fromPrivate(BigInteger.TEN); // An example private key.
assertEquals("pub:04a0434d9e47f3c86235477c7b1ae6ae5d3442d49b1943c2b752a68e2a47e247c7893aba425419bc27a3b6c7e693a24c696f794c2ed877a1593cbee53b037368d7", key.toString());
}
} |
24503275_7 | class ECKey implements Serializable {
public boolean isPubKeyCanonical() {
return isPubKeyCanonical(pub.getEncoded());
}
public ECKey();
public ECKey(SecureRandom secureRandom);
protected ECKey(@Nullable BigInteger priv, ECPoint pub);
public static ECPoint compressPoint(ECPoint unc... | // Test correct prefix 4, right length 65
byte[] canonicalPubkey1 = new byte[65]; canonicalPubkey1[0] = 0x04;
assertTrue(ECKey.isPubKeyCanonical(canonicalPubkey1));
// Test correct prefix 2, right length 33
byte[] canonicalPubkey2 = new byte[33]; canonicalPubkey2[0] = 0x02;
assertTrue(ECKey.isPubKeyCanonica... |
24503275_8 | class ECKey implements Serializable {
public boolean isPubKeyCanonical() {
return isPubKeyCanonical(pub.getEncoded());
}
public ECKey();
public ECKey(SecureRandom secureRandom);
protected ECKey(@Nullable BigInteger priv, ECPoint pub);
public static ECPoint compressPoint(ECPoint unc... | // Test correct prefix 4, but wrong length !65
byte[] nonCanonicalPubkey1 = new byte[64]; nonCanonicalPubkey1[0] = 0x04;
assertFalse(ECKey.isPubKeyCanonical(nonCanonicalPubkey1));
// Test correct prefix 2, but wrong length !33
byte[] nonCanonicalPubkey2 = new byte[32]; nonCanonicalPubkey2[0] = 0x02;
assertF... |
24503275_9 | class ECKey implements Serializable {
public boolean isPubKeyCanonical() {
return isPubKeyCanonical(pub.getEncoded());
}
public ECKey();
public ECKey(SecureRandom secureRandom);
protected ECKey(@Nullable BigInteger priv, ECPoint pub);
public static ECPoint compressPoint(ECPoint unc... | // Test wrong prefix 4, right length 65
byte[] nonCanonicalPubkey4 = new byte[65];
assertFalse(ECKey.isPubKeyCanonical(nonCanonicalPubkey4));
// Test wrong prefix 2, right length 33
byte[] nonCanonicalPubkey5 = new byte[33];
assertFalse(ECKey.isPubKeyCanonical(nonCanonicalPubkey5));
// Test wrong prefix 3... |
25259107_0 | class SignResponse extends JsonSerializable implements Persistable {
public static SignResponse fromJson(String json) throws U2fBadInputException {
checkArgument(json.length() < MAX_SIZE, "Client response bigger than allowed");
return fromJson(json, SignResponse.class);
}
@JsonCreator publ... | SignResponse.fromJson(makeLongJson(20000));
fail("fromJson did not detect too long JSON content.");
}
} |
25259107_1 | class SignResponse extends JsonSerializable implements Persistable {
public static SignResponse fromJson(String json) throws U2fBadInputException {
checkArgument(json.length() < MAX_SIZE, "Client response bigger than allowed");
return fromJson(json, SignResponse.class);
}
@JsonCreator publ... | assertNotNull(SignResponse.fromJson(makeLongJson(19999)));
}
} |
25259107_2 | class SignRequest extends JsonSerializable implements Persistable {
public String getRequestId() {
return challenge;
}
public static SignRequest fromJson(String json);
public static final String JSON;
}
class SignRequestTest {
public static final String JSON;
@Test
public void... | SignRequest signRequest = SignRequest.builder().challenge(SERVER_CHALLENGE_SIGN_BASE64).appId(APP_ID_SIGN).keyHandle(KEY_HANDLE_BASE64).build();
assertEquals(SERVER_CHALLENGE_SIGN_BASE64, signRequest.getChallenge());
assertEquals(SERVER_CHALLENGE_SIGN_BASE64, signRequest.getRequestId());
... |
25259107_3 | class JsonSerializable {
@Override
public String toString() {
return toJson();
}
@JsonIgnore public String toJson();
public static T fromJson(String json, Class<T> cls);
}
class JsonSerializableTest {
@Test
public void toStringReturnsJson() {
| assertEquals("{\"foo\":\"bar\"}", new Thing("bar").toString());
}
} |
25259107_4 | class ClientData {
public static String canonicalizeOrigin(String url) {
try {
URI uri = new URI(url);
if (uri.getAuthority() == null) {
return url;
}
return uri.getScheme() + "://" + uri.getAuthority();
} catch (URISyntaxException e) ... | assertEquals("http://example.com", canonicalizeOrigin("http://example.com"));
assertEquals("http://example.com", canonicalizeOrigin("http://example.com/"));
assertEquals("http://example.com", canonicalizeOrigin("http://example.com/foo"));
assertEquals("http://example.com", canonicalizeOr... |
25259107_6 | class RegisterRequest extends JsonSerializable implements Persistable {
@Override
public String getRequestId() {
return getChallenge();
}
public RegisterRequest(String challenge, String appId);
public static RegisterRequest fromJson(String json);
public static final String JSON;
}
... | RegisterRequest registerRequest = new RegisterRequest(SERVER_CHALLENGE_REGISTER_BASE64, APP_ID_ENROLL);
assertEquals(SERVER_CHALLENGE_REGISTER_BASE64, registerRequest.getChallenge());
assertEquals(APP_ID_ENROLL, registerRequest.getAppId());
assertNotNull(SERVER_CHALLENGE_REGISTER_BASE64,... |
25259107_7 | class RegisterRequest extends JsonSerializable implements Persistable {
public static RegisterRequest fromJson(String json) throws U2fBadInputException {
return fromJson(json, RegisterRequest.class);
}
public RegisterRequest(String challenge, String appId);
@Override public String getRequest... | RegisterRequest registerRequest = RegisterRequest.fromJson(JSON);
RegisterRequest registerRequest2 = TestUtils.clone(registerRequest);
assertEquals(registerRequest, registerRequest2);
}
} |
25259107_8 | class RegisterResponse extends JsonSerializable implements Persistable {
public static RegisterResponse fromJson(String json) throws U2fBadInputException {
checkArgument(json.length() < MAX_SIZE, "Client response bigger than allowed");
return JsonSerializable.fromJson(json, RegisterResponse.class);... | RegisterResponse.fromJson(makeLongJson(20000));
fail("fromJson did not detect too long JSON content.");
}
} |
25259107_9 | class RegisterResponse extends JsonSerializable implements Persistable {
public static RegisterResponse fromJson(String json) throws U2fBadInputException {
checkArgument(json.length() < MAX_SIZE, "Client response bigger than allowed");
return JsonSerializable.fromJson(json, RegisterResponse.class);... | assertNotNull(RegisterResponse.fromJson(makeLongJson(19999)));
}
} |
25434304_0 | class Naming {
static String normalize(CharSequence name) {
return capitalize(name.toString().replaceFirst("^_", ""))
.replaceFirst("^Class$", "Class_");
}
private Naming();
static String withGeneratedSuffix(CharSequence what);
private static String capitalize(String name... | assertThat(Naming.normalize("_class"), equalTo("Class_"));
}
} |
25434304_1 | class Naming {
static String normalize(CharSequence name) {
return capitalize(name.toString().replaceFirst("^_", ""))
.replaceFirst("^Class$", "Class_");
}
private Naming();
static String withGeneratedSuffix(CharSequence what);
private static String capitalize(String name... | assertThat(Naming.normalize("_public"), equalTo("Public"));
}
} |
25434304_2 | class MatcherFactoryGenerator extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
try {
if (roundEnv.processingOver()) {
return false;
}
if (annotations.isEmpty()) {
... | matcherFactoryGenerator.process(annotations, env);
verify(env).processingOver();
verifyNoMoreInteractions(env);
}
} |
25434304_3 | class ElementParentsIterable implements Iterable<Element> {
public static Stream<Element> stream(Element element) {
return StreamSupport.stream(new ElementParentsIterable(element).spliterator(), false);
}
public ElementParentsIterable(Element start);
@Override public Iterator<Element> iterat... | TypeElement twiceNested = compilation.getElements()
.getTypeElement(Outer.Nested.TwiceNested.class.getCanonicalName());
List<? extends Element> members = compilation.getElements().getAllMembers(twiceNested);
Element field = members.stream().filter(ofKind(ElementKind.FIELD)).find... |
25434304_4 | class ElementParentsIterable implements Iterable<Element> {
public static Stream<Element> stream(Element element) {
return StreamSupport.stream(new ElementParentsIterable(element).spliterator(), false);
}
public ElementParentsIterable(Element start);
@Override public Iterator<Element> iterat... | PackageElement pkg = compilation.getElements()
.getPackageElement(Outer.class.getPackage().getName());
assertThat(stream(pkg).count(), is(0L));
}
} |
27062690_0 | class XModifier {
private void create(Node parent, XModifyNode node) throws XPathExpressionException {
Node newNode;
if (node.isAttributeModifier()) {
//attribute
createAttributeByXPath(parent, node.getCurNode().substring(1), node.getValue());
} else {
//... | Document document = createDocument();
Document documentExpected = readDocument("createExpected.xml");
XModifier modifier = new XModifier(document);
modifier.setNamespace("ns", "http://localhost");
// create an empty element
modifier.addModify("/ns:root/ns:element1");
... |
27187107_2 | class ZkUtils {
public static Stream<String> getAllChildren(CuratorFramework curator, String parentPath) {
String parentPath0 = removeEnd(parentPath, "/");
return getAllChildren0(curator, parentPath0).map(p -> removeStart(p, parentPath0));
}
private ZkUtils();
public static String ge... | ZkUtils.setToZk(curatorFramework, "/all/test1/a", "a".getBytes());
ZkUtils.setToZk(curatorFramework, "/all/test1/b", "b".getBytes());
ZkUtils.setToZk(curatorFramework, "/all/test1/b/c", "c".getBytes());
ZkUtils.setToZk(curatorFramework, "/all/test1/b/c/c1", "c1".getBytes());
ZkUt... |
27187107_3 | class ZkUtils {
public static Stream<ChildData> getAllChildrenWithData(CuratorFramework curator, String parentPath){
String parentPath0 = removeEnd(parentPath, "/");
return getAllChildrenWithData0(curator, parentPath0);
}
private ZkUtils();
public static String getStringFromZk(Curato... | ZkUtils.setToZk(curatorFramework, "/all/test3/a", "a".getBytes());
ZkUtils.setToZk(curatorFramework, "/all/test3/b", "b".getBytes());
ZkUtils.setToZk(curatorFramework, "/all/test3/b/c", "c".getBytes());
ZkUtils.setToZk(curatorFramework, "/all/test3/b/c/c1", "c1".getBytes());
ZkUt... |
27187107_4 | class ZkBasedTreeNodeResource implements Closeable {
@Override
public void close() {
synchronized (lock) {
if (resource != null && cleanup != null) {
cleanup.test(resource);
}
if (treeCache != null) {
treeCache.close();
}
... | ZkBasedTreeNodeResource<Map<String, String>> tree = ZkBasedTreeNodeResource
.<Map<String, String>> newBuilder()
.curator(curatorFramework)
.path("/test")
.factory(p -> p.entrySet().stream()
.collect(toMap(Entry::getKey, e ->... |
29774200_1 | class SonarConnectionFactory {
public SonarConnection create(String url, String login, String password) {
Preconditions.checkNotNull(url, "url is mandatory");
SonarConnection sonarConnection = new SonarConnection();
sonarConnection.connect(url, login, password);
return sonarConnecti... | SonarConnection connection = sonarConnectionFactory.create("http://sonar:9000", "", "");
assertFalse(connection.isClosed());
}
} |
29774200_2 | class SonarCompatibleVersionChecker {
public boolean versionIsCompatible(String version) {
try {
double versionAsFloat = Double.valueOf(version);
return versionIsCompatible(versionAsFloat);
} catch (Exception e) {
return false;
}
}
public SonarC... | assertFalse(checker.versionIsCompatible(1.0));
}
} |
29774200_3 | class SonarCompatibleVersionChecker {
public boolean versionIsCompatible(String version) {
try {
double versionAsFloat = Double.valueOf(version);
return versionIsCompatible(versionAsFloat);
} catch (Exception e) {
return false;
}
}
public SonarC... | assertFalse(checker.versionIsCompatible(2.0));
}
} |
29774200_4 | class SonarCompatibleVersionChecker {
public boolean versionIsCompatible(String version) {
try {
double versionAsFloat = Double.valueOf(version);
return versionIsCompatible(versionAsFloat);
} catch (Exception e) {
return false;
}
}
public SonarC... | assertFalse(checker.versionIsCompatible(2.3));
}
} |
29774200_5 | class SonarCompatibleVersionChecker {
public boolean versionIsCompatible(String version) {
try {
double versionAsFloat = Double.valueOf(version);
return versionIsCompatible(versionAsFloat);
} catch (Exception e) {
return false;
}
}
public SonarC... | assertTrue(checker.versionIsCompatible(3.0));
}
} |
29774200_6 | class SonarCompatibleVersionChecker {
public boolean versionIsCompatible(String version) {
try {
double versionAsFloat = Double.valueOf(version);
return versionIsCompatible(versionAsFloat);
} catch (Exception e) {
return false;
}
}
public SonarC... | assertTrue(checker.versionIsCompatible(2.4));
}
} |
29774200_7 | class SonarCompatibleVersionChecker {
public boolean versionIsCompatible(String version) {
try {
double versionAsFloat = Double.valueOf(version);
return versionIsCompatible(versionAsFloat);
} catch (Exception e) {
return false;
}
}
public SonarC... | assertTrue(checker.versionIsCompatible(2.5));
}
} |
29774200_8 | class SonarCompatibleVersionChecker {
public boolean versionIsCompatible(String version) {
try {
double versionAsFloat = Double.valueOf(version);
return versionIsCompatible(versionAsFloat);
} catch (Exception e) {
return false;
}
}
public SonarC... | assertTrue(checker.versionIsCompatible(2.12));
}
} |
29774200_9 | class SonarCompatibleVersionChecker {
public boolean versionIsCompatible(String version) {
try {
double versionAsFloat = Double.valueOf(version);
return versionIsCompatible(versionAsFloat);
} catch (Exception e) {
return false;
}
}
public SonarC... | assertTrue(checker.versionIsCompatible("2.4"));
}
} |
32651977_0 | class Util {
public static String removeFirstAndLastChar(String text) {
Preconditions.checkNotNull(text, "text can not be null");
int n = text.length();
return text.substring(1, n - 1);
}
private Util();
public static String getFileName(String fullPath);
}
class UtilTest {
... | assertEquals("abc", removeFirstAndLastChar("\"abc\""));
}
} |
32651977_1 | class CompositeFileReader implements FileReader {
@Nullable
@Override
public CharStream read(String name) {
for (FileReader delegate : delegateList) {
CharStream result = delegate.read(name);
if (result != null) {
return result;
}
}
... | TestReader r1 = new TestReader("1.proto", "1");
TestReader r2 = new TestReader("2.proto", "2");
CompositeFileReader reader = new CompositeFileReader(r1, r2);
CharStream s1 = reader.read("1.proto");
CharStream s2 = reader.read("2.proto");
CharStream s3 = reader.read("3.pro... |
32651977_2 | class ClasspathFileReader implements FileReader {
@Nullable
@Override
public CharStream read(String name) {
try {
InputStream resource = readResource(name);
if (resource != null) {
return CharStreams.fromStream(resource);
}
} catch (Except... | ClasspathFileReader reader = new ClasspathFileReader();
CharStream a = reader.read("protostuff_unittest/messages_sample.proto");
CharStream b = reader.read("this_file_does_not_exist.proto");
assertNotNull(a);
assertNull(b);
}
} |
32651977_3 | class UserTypeValidationPostProcessor implements ProtoContextPostProcessor {
@VisibleForTesting
boolean isValidTagValue(int tag) {
return tag >= MIN_TAG && tag <= MAX_TAG
&& !(tag >= SYS_RESERVED_START && tag <= SYS_RESERVED_END);
}
@Override public void process(ProtoContext co... | assertFalse(processor.isValidTagValue(-1));
assertFalse(processor.isValidTagValue(0));
assertFalse(processor.isValidTagValue(19000));
assertFalse(processor.isValidTagValue(19999));
assertFalse(processor.isValidTagValue(Field.MAX_TAG_VALUE+1));
assertTrue(processor.isValid... |
32651977_4 | class LocalFileReader implements FileReader {
@Nullable
@Override
public CharStream read(String name) {
for (Path prefix : pathList) {
Path path = prefix.resolve(name);
if (Files.isRegularFile(path)) {
try {
byte[] bytes = Files.readAllByt... | LocalFileReader reader = new LocalFileReader(tempDirectory1, tempDirectory2);
CharStream a = reader.read("1.proto");
CharStream b = reader.read("2.proto");
CharStream c = reader.read("3.proto");
assertNotNull(a);
assertNotNull(b);
assertNull(c);
assertEqua... |
32651977_5 | class ScalarFieldTypeUtil {
@Nonnull
public static String getWrapperType(ScalarFieldType type) {
return getNonNull(WRAPPER_TYPE, type);
}
private ScalarFieldTypeUtil();
@Nonnull public static String getPrimitiveType(ScalarFieldType type);
@Nonnull public static String getDefaultValue... | assertEquals("Integer", ScalarFieldTypeUtil.getWrapperType(INT32));
}
} |
32651977_6 | class ScalarFieldTypeUtil {
@Nonnull
public static String getWrapperType(ScalarFieldType type) {
return getNonNull(WRAPPER_TYPE, type);
}
private ScalarFieldTypeUtil();
@Nonnull public static String getPrimitiveType(ScalarFieldType type);
@Nonnull public static String getDefaultValue... | Assertions.assertThrows(IllegalArgumentException.class,
() -> ScalarFieldTypeUtil.getWrapperType(null));
}
} |
32651977_7 | class ScalarFieldTypeUtil {
@Nonnull
public static String getPrimitiveType(ScalarFieldType type) {
return getNonNull(PRIMITIVE_TYPE, type);
}
private ScalarFieldTypeUtil();
@Nonnull public static String getWrapperType(ScalarFieldType type);
@Nonnull public static String getDefaultVal... | assertEquals("int", ScalarFieldTypeUtil.getPrimitiveType(INT32));
}
} |
32651977_8 | class ScalarFieldTypeUtil {
@Nonnull
public static String getDefaultValue(ScalarFieldType type) {
return getNonNull(DEFAULT_VALUE, type);
}
private ScalarFieldTypeUtil();
@Nonnull public static String getWrapperType(ScalarFieldType type);
@Nonnull public static String getPrimitiveTyp... | assertEquals("0", ScalarFieldTypeUtil.getDefaultValue(INT32));
}
} |
32651977_9 | class MessageFieldUtil {
public static String bitFieldName(Field field) {
return "__bitField" + (field.getIndex() - 1) / 32;
}
private MessageFieldUtil();
public static String getFieldType(Field field);
public static String getFieldName(Field field);
public static String getJsonField... | assertEquals("__bitField0", MessageFieldUtil.bitFieldName(f1));
assertEquals("__bitField0", MessageFieldUtil.bitFieldName(f32));
assertEquals("__bitField1", MessageFieldUtil.bitFieldName(f33));
}
} |
33329835_1 | class EbtsUtils {
public static int byteArrayToInt(final byte[] bytes) {
if (bytes.length == 4) {
return Ints.fromByteArray(bytes);
} else if (bytes.length == 2) {
return Shorts.fromByteArray(bytes);
} else if (bytes.length == 1) {
return bytes[0] & 0xff... | byte[] data = new byte[4];
data[0] = 0x00;
data[1] = 0x00;
data[2] = (byte) 0x98;
data[3] = (byte) 0xF2;
int val = EbtsUtils.byteArrayToInt(data);
assertEquals(39154,val);
log.debug("{}",val);
data = new byte[1];
data[0] = (byte) 0xFF;
... |
33329835_2 | class EbtsParser {
public static Ebts parse(final byte[] bytes, final ParseType parseType) throws EbtsParsingException {
return EbtsParser.parse(bytes,parseType,Type7Handling.TREAT_AS_TYPE4);
}
public EbtsParser();
public static Ebts parse(final byte[] bytes, Type7Handling type7Handling);
... | File file = new File(ClassLoader.getSystemResource("EFT/S001-01-t10_01.eft").toURI());
EbtsParser ebtsParser = new EbtsParser();
Ebts ebtsDescriptiveOnly = ebtsParser.parse(file,ParseType.DESCRIPTIVE_ONLY);
Ebts ebts = ebtsParser.parse(file,ParseType.FULL);
//Type 1 and 2 only... |
33329835_3 | class EbtsParser {
public static Ebts parse(final byte[] bytes, final ParseType parseType) throws EbtsParsingException {
return EbtsParser.parse(bytes,parseType,Type7Handling.TREAT_AS_TYPE4);
}
public EbtsParser();
public static Ebts parse(final byte[] bytes, Type7Handling type7Handling);
... | File file = new File(ClassLoader.getSystemResource("EFT/empty_image.eft").toURI());
EbtsParser ebtsParser = new EbtsParser();
//previously threw exception
Ebts ebts = ebtsParser.parse(file,ParseType.FULL);
assertNotNull(ebts);
GenericRecord type10 = (GenericRecord) ebts... |
33329835_5 | class EbtsBuilder {
public byte[] build(final Ebts ebts) throws EbtsBuildingException {
this.ebts = ebts;
//Create the auto-expanding output stream
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
//Get list of all records
//Overwrite CNT field(1.03)
f... | Ebts ebts = new Ebts();
GenericRecord type1 = new GenericRecord(1);
type1.setField(3, new Field("0400"));
type1.setField(8, new Field("WVMEDS001"));
GenericRecord type2 = new GenericRecord(2);
type2.setField(2, new Field("04"));
type2.setField(19, new Field("Smit... |
33403291_0 | class MinecraftlyUtil {
public static long convertMillisToTicks( long milliseconds ) {
double nearestTickTime = round( milliseconds, 50 );
return (long) ((nearestTickTime / 1000) * 20);
}
public static UUID convertFromNoDashes( String uuidString );
public static String convertToNoDashes( UUID uuid );
public ... |
Assert.assertEquals( 1, MinecraftlyUtil.convertMillisToTicks( 40 ) );
Assert.assertEquals( 1, MinecraftlyUtil.convertMillisToTicks( 50 ) );
Assert.assertEquals( 1, MinecraftlyUtil.convertMillisToTicks( 60 ) );
Assert.assertEquals( 3, MinecraftlyUtil.convertMillisToTicks( 140 ) );
Assert.assertEquals( 3, Min... |
34599551_1 | class HelloWorldEndpointImpl implements HelloWorldPortType {
@Override
public Greeting sayHello(Person person) {
String firstName = person.getFirstName();
LOGGER.debug("firstName={}", firstName);
String lasttName = person.getLastName();
LOGGER.debug("lastName={}", lasttName);
... | Person person = new Person();
person.setFirstName("John");
person.setLastName("Watson");
assertEquals("Hello John Watson!", new HelloWorldClientImplMock(
ENDPOINT_ADDRESS).sayHello(person, "john.watson", "w4750n"));
}
} |
34599551_2 | class HelloWorldEndpointImpl implements HelloWorldPortType {
@Override
public Greeting sayHello(Person person) {
String firstName = person.getFirstName();
LOGGER.debug("firstName={}", firstName);
String lasttName = person.getLastName();
LOGGER.debug("lastName={}", lasttName);
... | Person person = new Person();
person.setFirstName("Marie");
person.setLastName("Hudson");
try {
new HelloWorldClientImplMock(ENDPOINT_ADDRESS).sayHello(person);
fail("no credentials should fail");
} catch (SOAPFaultException soapFaultException) {
... |
34599551_3 | class HelloWorldEndpointImpl implements HelloWorldPortType {
@Override
public Greeting sayHello(Person person) {
String firstName = person.getFirstName();
LOGGER.debug("firstName={}", firstName);
String lasttName = person.getLastName();
LOGGER.debug("lastName={}", lasttName);
... | Person person = new Person();
person.setFirstName("Mycroft");
person.setLastName("Holmes");
try {
new HelloWorldClientImplMock(ENDPOINT_ADDRESS).sayHello(person,
"mycroft.holmes", "h0lm35");
fail("unknown user should fail");
} catch (... |
34599551_4 | class HelloWorldEndpointImpl implements HelloWorldPortType {
@Override
public Greeting sayHello(Person person) {
String firstName = person.getFirstName();
LOGGER.debug("firstName={}", firstName);
String lasttName = person.getLastName();
LOGGER.debug("lastName={}", lasttName);
... | Person person = new Person();
person.setFirstName("Jim");
person.setLastName("Moriarty");
try {
new HelloWorldClientImplMock(ENDPOINT_ADDRESS).sayHello(person,
"jim.moriarty", "moriarty");
fail("incorrect password should fail");
} cat... |
34599551_5 | class HelloWorldClientImpl {
public String sayHello(Person person, String userName, String password) {
setBasicAuthentication(userName, password);
return sayHello(person);
}
public HelloWorldClientImpl(Bus bus);
private String sayHello(Person person);
private void setBasicAuthen... | Person person = new Person();
person.setFirstName("Sherlock");
person.setLastName("Holmes");
assertEquals("Hello Sherlock Holmes!", helloWorldClientImpl.sayHello(
person, "sherlock.holmes", "h0lm35"));
}
} |
34599551_6 | class HelloWorldClientImpl {
public String sayHello(Person person) {
Greeting greeting = helloWorldJaxWsProxyBean.sayHello(person);
String result = greeting.getText();
LOGGER.info("result={}", result);
return result;
}
private static String ENDPOINT_ADDRESS;
@Autowired... | Person person = new Person();
person.setFirstName("Sherlock");
person.setLastName("Holmes");
assertEquals("Hello Sherlock Holmes!",
helloWorldClientImplBean.sayHello(person));
}
} |
34599551_7 | class HelloWorldEndpointImpl implements HelloWorldPortType {
@Override
public Greeting sayHello(Person person) {
String firstName = person.getFirstName();
LOGGER.debug("firstName={}", firstName);
String lasttName = person.getLastName();
LOGGER.debug("lastName={}", lasttName);
... | Person person = new Person();
person.setFirstName("John");
person.setLastName("Watson");
assertEquals("Hello John Watson!", new HelloWorldClientImplMock(
ENDPOINT_ADDRESS).sayHello(person));
}
} |
34599551_8 | class HelloWorldClientImpl {
public String sayHello(Person person) {
Greeting greeting = helloWorldClientBean.sayHello(person);
String result = greeting.getText();
LOGGER.info("result={}", result);
return result;
}
private static String ENDPOINT_ADDRESS;
@Autowired
... | Person person = new Person();
person.setFirstName("Sherlock");
person.setLastName("Holmes");
assertEquals("Hello Sherlock Holmes!",
helloWorldClientImplBean.sayHello(person));
}
} |
35957836_1 | class LanguageStats {
public static List<LanguageStats> buildStats(List<Project> projectList) {
List<Project> projects = filterUniqueSnapshots(projectList);
// For each date, we have a map of all the counts. Later we piece the
// results together from these pieces of information.
M... | assertThat(LanguageStats.buildStats(Lists.newArrayList()), empty());
}
} |
35957836_2 | class LanguageStats {
public static List<LanguageStats> buildStats(List<Project> projectList) {
List<Project> projects = filterUniqueSnapshots(projectList);
// For each date, we have a map of all the counts. Later we piece the
// results together from these pieces of information.
M... | Date snapshotDate = new Date();
Project javaProject = new Project();
javaProject.setName("Project 1");
javaProject.setPrimaryLanguage(JAVA);
javaProject.setSnapshotDate(snapshotDate);
Project pythonProject = new Project();
pythonProject.setName("Project 2");
... |
35957836_3 | class LanguageStats {
public static List<LanguageStats> buildStats(List<Project> projectList) {
List<Project> projects = filterUniqueSnapshots(projectList);
// For each date, we have a map of all the counts. Later we piece the
// results together from these pieces of information.
M... | Date snapshotDate = new Date();
Project javaProject = new Project();
javaProject.setName("Project 1");
javaProject.setPrimaryLanguage(JAVA);
javaProject.setSnapshotDate(snapshotDate);
Project duplicateProject = new Project();
duplicateProject.setName("Project 1"... |
35957836_4 | class Scorer {
public int score(Project project) {
String jsCode = "";
jsCode += "var scoring = " + scoringProject + ";\n";
jsCode += "result.value = scoring(project);";
return ((Number) newExecutor(jsCode).bind("project", project).execute()).intValue();
}
... |
// given
Scorer scorer = new Scorer();
scorer.setScoringProject("function(project) { return project.forksCount > 0 ? ( "
+ "project.starsCount + project.forksCount + project.contributorsCount + "
+ "project.commitsCount / 100 ) : 0 }");
// when
P... |
35957836_5 | class Contributor {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Contributor {\n");
sb.append(" id: ").append(getId()).append("\n");
sb.append(" organizationId: ").append(getOrganizationId()).append("\n");
sb.append(" name: ").append(name).append("\n");
... |
// given
Date date = new Date();
Contributor contributor = new Contributor(123456789, 987654321, date);
// when
String str = contributor.toString();
// then
assertThat(str, stringContainsInOrder(asList("id", ":", "123456789")));
assertThat(str, stringContainsInOrder(asList("organizationId", ":", "987... |
35957836_6 | class LanguageService {
public List<Language> getMainLanguages(final String organizations, final Comparator<Language> c, Optional<String> filterLanguage) {
Collection<String> organizationList = StringParser.parseStringList(organizations, ",");
List<Project> projectList = new ArrayList<>();
... |
logger.info("Setting up the projects...");
Project p1 = new ProjectBuilder().commitsCount(10)
.contributorsCount(5)
.forksCount(1)
.gitHubProjectId(12345)
.description("bogus project 1")
.name("bogus project 1")
... |
39215543_0 | class InstrumentedOkHttpClient extends OkHttpClient {
String metricId(String metric) {
return name(OkHttpClient.class, name, metric);
}
InstrumentedOkHttpClient(MetricRegistry registry, OkHttpClient rawClient, String name);
private void instrumentHttpCache();
private void instrumentConnectionPool();
... | String prefix = "custom";
String baseId = "network-requests-submitted";
assertThat(registry.getMeters()).isEmpty();
InstrumentedOkHttpClient client = new InstrumentedOkHttpClient(registry, rawClient, prefix);
String generatedId = client.metricId(baseId);
assertThat(registry.getMeters().get(ge... |
39215543_1 | class InstrumentedOkHttpClients {
public static OkHttpClient create(MetricRegistry registry) {
return new InstrumentedOkHttpClient(registry, new OkHttpClient(), null);
}
private InstrumentedOkHttpClients();
public static OkHttpClient create(MetricRegistry registry, OkHttpClient client);
public static ... | OkHttpClient client = InstrumentedOkHttpClients.create(registry);
// The connection, read, and write timeouts are the only configurations applied by default.
assertThat(client.connectTimeoutMillis()).isEqualTo(10_000);
assertThat(client.readTimeoutMillis()).isEqualTo(10_000);
assertThat(client.writ... |
39215543_2 | class InstrumentedOkHttpClients {
public static OkHttpClient create(MetricRegistry registry) {
return new InstrumentedOkHttpClient(registry, new OkHttpClient(), null);
}
private InstrumentedOkHttpClients();
public static OkHttpClient create(MetricRegistry registry, OkHttpClient client);
public static ... | OkHttpClient client = InstrumentedOkHttpClients.create(registry, "custom");
// The connection, read, and write timeouts are the only configurations applied by default.
assertThat(client.connectTimeoutMillis()).isEqualTo(10_000);
assertThat(client.readTimeoutMillis()).isEqualTo(10_000);
assertThat(c... |
39215543_3 | class InstrumentedOkHttpClients {
public static OkHttpClient create(MetricRegistry registry) {
return new InstrumentedOkHttpClient(registry, new OkHttpClient(), null);
}
private InstrumentedOkHttpClients();
public static OkHttpClient create(MetricRegistry registry, OkHttpClient client);
public static ... | OkHttpClient rawClient = new OkHttpClient();
OkHttpClient client = InstrumentedOkHttpClients.create(registry, rawClient);
assertThatClientsAreEqual(client, rawClient);
}
} |
39215543_4 | class InstrumentedOkHttpClients {
public static OkHttpClient create(MetricRegistry registry) {
return new InstrumentedOkHttpClient(registry, new OkHttpClient(), null);
}
private InstrumentedOkHttpClients();
public static OkHttpClient create(MetricRegistry registry, OkHttpClient client);
public static ... | OkHttpClient rawClient = new OkHttpClient();
OkHttpClient client = InstrumentedOkHttpClients.create(registry, rawClient, "custom");
assertThatClientsAreEqual(client, rawClient);
}
} |
39905754_0 | class Solution {
public List<String> fullJustify(String[] words, int maxWidth) {
List<String> output = new ArrayList<>();
int exclusiveStop = 0;
int start = 0;
while (exclusiveStop < words.length) {
exclusiveStop = exclusiveStop(words, start, maxWidth);
outpu... | Solution solution = new Solution();
List<String> result = solution.fullJustify(new String[] { "justification." }, 16);
assertEquals(Arrays.asList("justification. "), result);
}
} |
39905754_1 | class Solution {
public List<String> fullJustify(String[] words, int maxWidth) {
List<String> output = new ArrayList<>();
int exclusiveStop = 0;
int start = 0;
while (exclusiveStop < words.length) {
exclusiveStop = exclusiveStop(words, start, maxWidth);
outpu... | Solution solution = new Solution();
List<String> result = solution.fullJustify(new String[] { "0123456789ABCDE." }, 16);
assertEquals(Arrays.asList("0123456789ABCDE."), result);
}
} |
39905754_2 | class Solution {
public List<String> fullJustify(String[] words, int maxWidth) {
List<String> output = new ArrayList<>();
int exclusiveStop = 0;
int start = 0;
while (exclusiveStop < words.length) {
exclusiveStop = exclusiveStop(words, start, maxWidth);
outpu... | Solution solution = new Solution();
List<String> result = solution.fullJustify(new String[] { "This", "is", "an", "example", "of", "text", "justification." }, 16);
assertEquals(Arrays.asList("This is an", "example of text", "justification. "), result);
}
} |
39905754_3 | class Solution {
public List<String> fullJustify(String[] words, int maxWidth) {
List<String> output = new ArrayList<>();
int exclusiveStop = 0;
int start = 0;
while (exclusiveStop < words.length) {
exclusiveStop = exclusiveStop(words, start, maxWidth);
outpu... | Solution solution = new Solution();
List<String> result = solution.fullJustify(new String[] { "a", "b", "c" }, 1);
assertEquals(Arrays.asList("a", "b", "c"), result);
}
} |
39905754_4 | class Solution {
public List<String> fullJustify(String[] words, int maxWidth) {
List<String> output = new ArrayList<>();
int exclusiveStop = 0;
int start = 0;
while (exclusiveStop < words.length) {
exclusiveStop = exclusiveStop(words, start, maxWidth);
outpu... | Solution solution = new Solution();
List<String> result = solution.fullJustify(new String[] { "What", "must", "be", "shall", "be." }, 12);
assertEquals(Arrays.asList("What must be", "shall be. "), result);
}
} |
39905754_5 | class Solution {
public List<String> fullJustify(String[] words, int maxWidth) {
List<String> output = new ArrayList<>();
int exclusiveStop = 0;
int start = 0;
while (exclusiveStop < words.length) {
exclusiveStop = exclusiveStop(words, start, maxWidth);
outpu... | Solution solution = new Solution();
List<String> result = solution.fullJustify(new String[] { "" }, 2);
assertEquals(Arrays.asList(" "), result);
}
} |
39905754_6 | class Solution {
public List<String> fullJustify(String[] words, int maxWidth) {
List<String> output = new ArrayList<>();
int exclusiveStop = 0;
int start = 0;
while (exclusiveStop < words.length) {
exclusiveStop = exclusiveStop(words, start, maxWidth);
outpu... | Solution solution = new Solution();
List<String> result = solution.fullJustify(new String[] { "hello", ",", "world" }, 5);
assertEquals(Arrays.asList("hello", ", ", "world"), result);
}
} |
39905754_7 | class EightQueens {
static boolean isSolution(List<Position> board) {
int size = board.size();
for (int i = 0; i < size; i++) {
Position firstPosition = board.get(i);
if (firstPosition.intersectPositions(board, i)) {
return false;
}
}
... | List<Position> board = Arrays.asList(pos(0, 3),pos(1, 5), pos(2, 7), pos(3, 1),
pos(4, 6), pos(5, 0), pos(6, 2), pos(7, 4));
assertTrue(EightQueens.isSolution(board));
}
} |
39905754_8 | class EightQueens {
static boolean isSolution(List<Position> board) {
int size = board.size();
for (int i = 0; i < size; i++) {
Position firstPosition = board.get(i);
if (firstPosition.intersectPositions(board, i)) {
return false;
}
}
... | List<Position> board = Arrays.asList(pos(0, 3),pos(1, 5), pos(2, 7), pos(3, 1),
pos(4, 6), pos(5, 0), pos(7, 2), pos(7, 4));
assertFalse(EightQueens.isSolution(board));
}
} |
39905754_9 | class EightQueens {
static boolean isSolution(List<Position> board) {
int size = board.size();
for (int i = 0; i < size; i++) {
Position firstPosition = board.get(i);
if (firstPosition.intersectPositions(board, i)) {
return false;
}
}
... | List<Position> board = asList(pos(0, 3));
assertTrue(EightQueens.isSolution(board));
}
} |
42112681_0 | class Symbol {
public static String java2Elisp(String javaName) {
StringBuffer lispName = new StringBuffer();
boolean lastCharWasDash = false;
char prev = ' ';
for (int i = 0; i < javaName.length(); i++) {
char c = javaName.charAt(i);
if (!Character.isLe... | assertEquals("jdee-foo-call-left-right", Symbol.java2Elisp("jdeeFooCallLeftRight"));
}
} |
42112681_1 | class Symbol {
public static String java2Elisp(String javaName) {
StringBuffer lispName = new StringBuffer();
boolean lastCharWasDash = false;
char prev = ' ';
for (int i = 0; i < javaName.length(); i++) {
char c = javaName.charAt(i);
if (!Character.isLe... | assertEquals("jdee-foo-call-left-right", Symbol.java2Elisp("jdee.foo.Call.leftRight"));
}
} |
42112681_2 | class Symbol {
public static String java2Elisp(String javaName) {
StringBuffer lispName = new StringBuffer();
boolean lastCharWasDash = false;
char prev = ' ';
for (int i = 0; i < javaName.length(); i++) {
char c = javaName.charAt(i);
if (!Character.isLe... | assertEquals("jdee-foo-call-left-right", Symbol.java2Elisp("jdee.foo.CALL_LEFT_RIGHT"));
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.