<commit_before>package com.simplenote.android.net;

import junit.framework.TestCase;

import com.simplenote.android.Constants;
import com.simplenote.android.model.Note;
import com.simplenote.android.net.Api.Response;

/**
 * Exercise the SimpleNoteApi class
 * @author bryanjswift
 */
public class SimpleNoteApiTest extends TestCase {
	public static final String emailAddress = "<EMAIL>";
	public static final String password = "<PASSWORD>";
	public static final String LOGGING_TAG = Constants.TAG + "SimpleNoteApiTest";

	String noteBody;

	private abstract class FailingCallback extends HttpCallback {
		@Override
		public void on200(Response response) {
			fail("Should not have returned a 200 response code");
		}
		@Override
		public void on400(Response response) {
			fail("Should not have returned a 400 response code");
		}
		@Override
		public void on401(Response response) {
			fail("Should not have returned a 401 response code");
		}
		@Override
		public void on403(Response response) {
			fail("Should not have returned a 403 response code");
		}
		@Override
		public void on404(Response response) {
			fail("Should not have returned a 404 response code");
		}
		@Override
		public void on500(Response response) {
			fail("Should not have returned a 500 response code");
		}
		@Override
		public void onException(String url, String data, Throwable t) {
			fail("Should not have thrown an exception: " + t.getMessage());
		}
	}
	/**
	 * Test we are able to log in successfully
	 */
	public void testSuccessfulLogin() {
		SimpleNoteApi.login(emailAddress, password, new FailingCallback() {
			@Override
			public void on200(Response response) {
				assertTrue(response.body.length() > 0);
			}
		});
	}
	/**
	 * Test failed login gets a 401 response
	 */
	public void testFailingLogin() {
		SimpleNoteApi.login(emailAddress, "password", new FailingCallback() {
			@Override
			public void on401(Response response) {
				// if we are here we should pass
			}
		});
	}
	/**
	 * Test able to retrieve notes after successful login
	 */
	public void testIndexAndNoteRetrieval() {
		String validToken = SimpleNoteApi.login(emailAddress, password, new FailingCallback() {
			@Override
			public void on200(Response response) {
				assertTrue(response.body.length() > 0);
			}
		});
		Note[] notes = SimpleNoteApi.index(validToken, emailAddress, new FailingCallback() {
			@Override
			public void on200(Response response) {
				assertTrue(response.body.length() > 0);
			}
		});
		assertTrue(notes.length > 0);
		Note note = SimpleNoteApi.retrieve(notes[0], validToken, emailAddress, new FailingCallback() {
			@Override
			public void on200(Response response) {
				// If we are here we passed
				noteBody = response.body;
			}
		});
		assertEquals(note.getTitleAndBody(), noteBody);
	}
}
<commit_msg>Add (failing) test to try and update a note on the server<commit_after>package com.simplenote.android.net;

import junit.framework.TestCase;

import com.simplenote.android.Constants;
import com.simplenote.android.model.Note;
import com.simplenote.android.net.Api.Response;

/**
 * Exercise the SimpleNoteApi class
 * @author bryanjswift
 */
public class SimpleNoteApiTest extends TestCase {
	public static final String emailAddress = "<EMAIL>";
	public static final String password = "<PASSWORD>";
	public static final String LOGGING_TAG = Constants.TAG + "SimpleNoteApiTest";

	String noteBody;

	private abstract class FailingCallback extends HttpCallback {
		@Override
		public void on200(Response response) {
			fail("Should not have returned a 200 response code");
		}
		@Override
		public void on400(Response response) {
			fail("Should not have returned a 400 response code");
		}
		@Override
		public void on401(Response response) {
			fail("Should not have returned a 401 response code");
		}
		@Override
		public void on403(Response response) {
			fail("Should not have returned a 403 response code");
		}
		@Override
		public void on404(Response response) {
			fail("Should not have returned a 404 response code");
		}
		@Override
		public void on500(Response response) {
			fail("Should not have returned a 500 response code");
		}
		@Override
		public void onException(String url, String data, Throwable t) {
			fail("Should not have thrown an exception: " + t.getMessage());
		}
	}
	/**
	 * Test we are able to log in successfully
	 */
	public void testSuccessfulLogin() {
		SimpleNoteApi.login(emailAddress, password, new FailingCallback() {
			@Override
			public void on200(Response response) {
				assertTrue(response.body.length() > 0);
			}
		});
	}
	/**
	 * Test failed login gets a 401 response
	 */
	public void testFailingLogin() {
		SimpleNoteApi.login(emailAddress, "password", new FailingCallback() {
			@Override
			public void on401(Response response) {
				// if we are here we should pass
			}
		});
	}
	/**
	 * Test able to retrieve notes after successful login
	 */
	public void testIndexAndNoteRetrieval() {
		String validToken = SimpleNoteApi.login(emailAddress, password, new FailingCallback() {
			@Override
			public void on200(Response response) {
				assertTrue(response.body.length() > 0);
			}
		});
		Note[] notes = SimpleNoteApi.index(validToken, emailAddress, new FailingCallback() {
			@Override
			public void on200(Response response) {
				assertTrue(response.body.length() > 0);
			}
		});
		assertTrue(notes.length > 0);
		Note note = SimpleNoteApi.retrieve(notes[0], validToken, emailAddress, new FailingCallback() {
			@Override
			public void on200(Response response) {
				// If we are here we passed
				noteBody = response.body;
			}
		});
		assertEquals(note.getTitleAndBody(), noteBody);
	}
	/**
	 * Test we are able to update notes
	 */
	public void testNoteUpdate() {
		String validToken = SimpleNoteApi.login(emailAddress, password, new FailingCallback() {
			@Override
			public void on200(Response response) {
				assertTrue(response.body.length() > 0);
			}
		});
		Note[] notes = SimpleNoteApi.index(validToken, emailAddress, new FailingCallback() {
			@Override
			public void on200(Response response) {
				assertTrue(response.body.length() > 0);
			}
		});
		assertTrue(notes.length > 0);
		final Note serverNote = SimpleNoteApi.retrieve(notes[0], validToken, emailAddress, new FailingCallback() {
			@Override
			public void on200(Response response) {
				// If we are here we passed
				noteBody = response.body;
			}
		});
		assertEquals(serverNote.getTitleAndBody(), noteBody);
		final Note newNote = serverNote.setBody(serverNote.getBody() + "\n Test appended");
		SimpleNoteApi.update(newNote, validToken, emailAddress, new FailingCallback() {
			@Override
			public void on200(Response response) {
				// passed
			}
		});
	}
}

{'fraction_non_alphanumeric': 0.10581222056631892, 'fraction_numerical': 0.019970193740685545, 'mean_word_length': 3.978486646884273, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4260220', 'n_tokens_mistral': 2299, 'n_tokens_neox': 1935, 'n_words': 592}