<commit_before>/* Description: jUnit tests for testing CRUD related features inside item_page
 * Author: <NAME>
 * Email: <EMAIL>
 */
/*package ca.ualberta.cs.cmput301w15t12.test;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import ca.ualberta.cs.cmput301w15t12.AddItemActivity;
import ca.ualberta.cs.cmput301w15t12.AlreadyExistsException;
import ca.ualberta.cs.cmput301w15t12.ClaimListController;
import ca.ualberta.cs.cmput301w15t12.ExpenseItem;
import ca.ualberta.cs.cmput301w15t12.R;
import ca.ualberta.cs.cmput301w15t12.User;
import ca.ualberta.cs.cmput301w15t12.UserListController;


public class ReceiptPhotoCRUDTest extends ActivityInstrumentationTestCase2<AddItemActivity> {

	public SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy", Locale.US);
	
	public ReceiptPhotoCRUDTest() {
		super(AddItemActivity.class);
	}
	
	protected void setUp() throws Exception {
		super.setUp();
		// Initialize currencies and categories list in ExpenseItem
		ExpenseItem.init(getInstrumentation().getTargetContext());
			
	}
	//[US06.01.01] - Taking photograph of a receipt
	public void testImageButton() throws ParseException, AlreadyExistsException{
		AddItemActivity activity = startExpenseItemActivity();
		View buttonImage=activity.findViewById(R.id.buttonAddImage);
		assertTrue("receiptImageView should be an instanceof Button",buttonImage.getClass() == Button.class);
	}	
	
	//[US06.03.01] - Retaking photograph of a receipt
	public void testDeleteImage() throws ParseException, AlreadyExistsException{
		AddItemActivity activity = startExpenseItemActivity();
		View view = activity.findViewById(R.id.buttonAddImage);
		activity.addImage(view);
		activity.deleteImage(view);
		assertEquals(view.getBackground(),android.R.drawable.btn_default);
	}
	
	//see [US06.02.01] and [US06.04.01] in ViewPhotoActivityTest.java

	
	
	private AddItemActivity startExpenseItemActivity() throws ParseException, AlreadyExistsException{
		//make a claim with an item
		User user  = new User("Freddie", "123");
		
		UserListController.getUserList().clear();
		UserListController.getUserList().addUser(user);
		
		Date d1 = df.parse("01/01/1200");
		Date d2 = df.parse("01/02/2134");
		
		ClaimListController clc = new ClaimListController();
		clc.clear();
		
		int id = clc.addClaim("name", d1, d2,"desc",user);
		ExpenseItem item = new ExpenseItem("name","","description","", new BigDecimal(66.69), new Date(), false);
		clc.getClaim(id).addItem(item);
		Intent intent = new Intent();
		intent.putExtra("claim_id",id);
		intent.putExtra("item_index",0);
		intent.putExtra("username","Freddie");
		intent.putExtra("option","Add");
		setActivityIntent(intent);
		return (AddItemActivity) getActivity();
	}

}
*/<commit_msg>removed commented lines<commit_after>/* Description: jUnit tests for testing CRUD related features inside item_page
 * Author: <NAME>
 * Email: <EMAIL>
 */
package ca.ualberta.cs.cmput301w15t12.test;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;
import android.view.View;
import android.widget.Button;
import ca.ualberta.cs.cmput301w15t12.AddItemActivity;
import ca.ualberta.cs.cmput301w15t12.AlreadyExistsException;
import ca.ualberta.cs.cmput301w15t12.ClaimListController;
import ca.ualberta.cs.cmput301w15t12.ExpenseItem;
import ca.ualberta.cs.cmput301w15t12.R;
import ca.ualberta.cs.cmput301w15t12.User;
import ca.ualberta.cs.cmput301w15t12.UserListController;


public class ReceiptPhotoCRUDTest extends ActivityInstrumentationTestCase2<AddItemActivity> {

	public SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy", Locale.US);
	
	public ReceiptPhotoCRUDTest() {
		super(AddItemActivity.class);
	}
	
	protected void setUp() throws Exception {
		super.setUp();
		// Initialize currencies and categories list in ExpenseItem
		ExpenseItem.init(getInstrumentation().getTargetContext());
			
	}
	//[US06.01.01] - Taking photograph of a receipt
	public void testImageButton() throws ParseException, AlreadyExistsException{
		AddItemActivity activity = startExpenseItemActivity();
		View buttonImage=activity.findViewById(R.id.buttonAddImage);
		assertTrue("receiptImageView should be an instanceof Button",buttonImage.getClass() == Button.class);
	}	
	
	//[US06.03.01] - Retaking photograph of a receipt
	public void testDeleteImage() throws ParseException, AlreadyExistsException{
		AddItemActivity activity = startExpenseItemActivity();
		View view = activity.findViewById(R.id.buttonAddImage);
		activity.addImage(view);
		activity.deleteImage(view);
		assertEquals(view.getBackground(),android.R.drawable.btn_default);
	}
	
	//see [US06.02.01] and [US06.04.01] in ViewPhotoActivityTest.java

	
	
	private AddItemActivity startExpenseItemActivity() throws ParseException, AlreadyExistsException{
		//make a claim with an item
		User user  = new User("Freddie", "123");
		
		UserListController.getUserList().clear();
		UserListController.getUserList().addUser(user);
		
		Date d1 = df.parse("01/01/1200");
		Date d2 = df.parse("01/02/2134");
		
		ClaimListController clc = new ClaimListController();
		clc.clear();
		
		int id = clc.addClaim("name", d1, d2,"desc",user);
		ExpenseItem item = new ExpenseItem("name","","description","", new BigDecimal(66.69), new Date(), false);
		clc.getClaim(id).addItem(item);
		Intent intent = new Intent();
		intent.putExtra("claim_id",id);
		intent.putExtra("item_index",0);
		intent.putExtra("username","Freddie");
		intent.putExtra("option","Add");
		setActivityIntent(intent);
		return (AddItemActivity) getActivity();
	}

}

{'fraction_non_alphanumeric': 0.12018826693561943, 'fraction_numerical': 0.03698100521095982, 'mean_word_length': 5.708004509582864, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '3440274', 'n_tokens_mistral': 2114, 'n_tokens_neox': 1848, 'n_words': 374}