@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_top); Customer cust=new Customer(); cust.setName("abc"); cust.setCity("xyz"); Intent intent=new Intent(abc.this,xyz.class); intent.putExtra("bundle",cust); startActivity(intent); }
private Customer cursorToCustomer(Cursor cursor) { Customer customer = new Customer(); customer.setCustomer(cursor.getString(0)); customer.setName(cursor.getString(1)); customer.setAddress1(cursor.getString(2)); customer.setAddress2(cursor.getString(3)); customer.setCity(cursor.getString(4)); customer.setState(cursor.getString(5)); customer.setZipCode(cursor.getString(6)); customer.setSearchValue(cursor.getString(7)); customer.setCarb(cursor.getString(8)); customer.setFiber(cursor.getString(9)); customer.setSugar(cursor.getString(10)); customer.setProtein(cursor.getString(11)); customer.setSodium(cursor.getString(12)); customer.setCalories(cursor.getString(13)); return comment; }
@Test public void updateCustomer_WithValidInput_ShouldReturnUpdatedInput(){ //given final Customer customer = new Customer(); customer.setId("123"); customer.setAddress("Addr1"); customer.setName("Bob"); customer.setCity("St8") customer.setLanguage("Java"); final CustomerInputData inputData = new CustomerInputData(); inputData.setId(customer.getId()); //when when(customerService.getCustomerById(customer.getId())).thenReturn(customer); classUnderTest.updateCustomer(customerData); //then verify(customerService.getCustomerById("123")); assertThat(customerData.getCustomerName(), equalTo(customer.getName())) // and so forth }
import org.springframework.batch.item.file.mapping.FieldSetMapper; import org.springframework.batch.item.file.transform.FieldSet; import org.springframework.validation.BindException; public class CustomerFieldSetMapper implements FieldSetMapper<Customer> { public Customer mapFieldSet(FieldSet fieldSet) throws BindException { Customer customer = new Customer(); customer.setAddress(fieldSet.readString("addressNumber") + " " + fieldSet.readString("street")); customer.setCity(fieldSet.readString("city")); customer.setFirstName(fieldSet.readString("firstName")); customer.setLastName(fieldSet.readString("lastName")); customer.setMiddleInitial(fieldSet.readString("middleInitial")); customer.setState(fieldSet.readString("state")); customer.setZip(fieldSet.readString("zip")); return customer; } }