public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof Address)) return false; Address other = (Address) obj; if (obj == null) return false; if (this == obj) return true; if (__equalsCalc != null) { return (__equalsCalc == obj); } __equalsCalc = obj; boolean _equals; _equals = true && ((this.street == null && other.getStreet() == null) || (this.street != null && this.street.equals(other.getStreet()))) && ((this.streetNo == null && other.getStreetNo() == null) || (this.streetNo != null && this.streetNo.equals(other.getStreetNo()))) && ((this.city == null && other.getCity() == null) || (this.city != null && this.city.equals(other.getCity()))) && ((this.county == null && other.getCounty() == null) || (this.county != null && this.county.equals(other.getCounty()))) && ((this.country == null && other.getCountry() == null) || (this.country != null && this.country.equals(other.getCountry()))) && ((this.zipCode == null && other.getZipCode() == null) || (this.zipCode != null && this.zipCode.equals(other.getZipCode()))) && ((this.notes == null && other.getNotes() == null) || (this.notes != null && this.notes.equals(other.getNotes()))) && this.isPrimary == other.isIsPrimary(); __equalsCalc = null; return _equals; }
private void write( final Address address, final MapquestResult.MapquestStatus status, final MapquestResult.Result result, final Status rejectCause) { // Why do I always have to go so dirty when writing files? final String[] fields = new String[18]; for (int i = 0; i < fields.length; i++) fields[i] = ""; if (address != null) { fields[0] = address.getId() != null ? address.getId() : ""; fields[1] = address.getStreet() != null ? address.getStreet() : ""; fields[2] = address.getNumber() != null ? address.getNumber() : ""; fields[3] = address.getZipcode() != null ? address.getZipcode() : ""; fields[4] = address.getMunicipality() != null ? address.getMunicipality() : ""; fields[5] = address.getCountry() != null ? address.getCountry() : ""; } if (rejectCause != null) { fields[6] = rejectCause.toString(); } if (result != null) { fields[7] = result.getLongitude().toString(); fields[8] = result.getLatitude().toString(); final Coord wgsCoord = new Coord(result.getLongitude(), result.getLatitude()); final Coord chCoord = new WGS84toCH1903LV03().transform(wgsCoord); fields[9] = "" + chCoord.getX(); fields[10] = "" + chCoord.getY(); fields[11] = result.getGeocodeQuality().toString(); fields[12] = result.getGeocodeQualityCode(); fields[13] = result.getStreet(); fields[14] = result.getZip(); fields[15] = result.getCity(); fields[16] = result.getCountry(); fields[17] = status.toString(); } final String line = CsvUtils.buildCsvLine(SEP, QUOTE, fields); try { this.writer.newLine(); this.writer.write(line); } catch (IOException e) { throw new UncheckedIOException(e); } }
/** * Accuracy test for the method <code>getCountry()</code>.<br> * The value should be properly retrieved. */ @Test public void test_getCountry() { Country value = new Country(); instance.setCountry(value); assertSame("'getCountry' should be correct.", value, instance.getCountry()); }
/** test the construction of the object in the ApplicationContext */ public final void testObjectConstruction() { // get a member from the application context Address address = CoreObjectFactory.getAddress(); assertEquals("City", null, address.getCity()); assertEquals("Country", null, address.getCountry()); assertEquals("PostalCode", null, address.getPostalCode()); assertEquals("StreetName", null, address.getStreetName()); assertEquals("StreetNumber", null, address.getStreetNumber()); }
public String getAddress() { return address.getCountry() + " " + address.getCity() + " " + address.getHouse(); }
/** POST /purchaseOrders -> Create a new purchaseOrder. */ @RequestMapping( value = "/purchaseOrders", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<?> createPurchaseOrder(@RequestBody List<PurchaseOrder> purchaseOrders) throws URISyntaxException, JsonProcessingException { log.debug("REST request to save PurchaseOrder : {}", purchaseOrders); if (purchaseOrders.size() == 0) { return ResponseEntity.badRequest() .headers(HeaderUtil.createFailureAlert("purchaseOrder", "noitems", "No items selected")) .body("{\"error\":\"NoItems\"}"); } // if (purchaseOrder.getId() != null) { // // } User loggedUser = userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get(); List<PurchaseOrder> initializedOrders = new ArrayList<PurchaseOrder>(); List<PurchaseOrder> result = new ArrayList<PurchaseOrder>(); String concatId = ""; Iterator<PurchaseOrder> it = purchaseOrders.iterator(); while (it.hasNext()) { PurchaseOrder order = it.next(); order.setState(OrderStatus.Initial); order.setCreationDate(ZonedDateTime.now()); ArtWorkPiece work = artWorkPieceRepository.findOne(order.getArtWorkPiece().getId()); if (work.getCommercialState() != CommercialState.ForSale || work.getApprovalState() != ApprovalState.Approved) { loggedUser = userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get(); ObjectMapper mapper = new ObjectMapper(); Set<WorkPiece> cart = loggedUser.getShoppingCart(); String cartJSON = mapper.writeValueAsString(cart); return ResponseEntity.badRequest() .headers( HeaderUtil.createFailureAlert( "purchaseOrder", "WorkNotForSale", "An artwork not for sale is trying to be selled")) .body("{\"error\":\"WorkNotForSale\",\"cart\":" + cartJSON + "}"); } User artist = userRepository.findOneByLogin(work.getProfile().getUser().getLogin()).get(); User client = loggedUser; order.setArtWorkPiece(work); order.setArtist(artist); order.setClient(client); Address origin; if (order.getArtist().getAddresses().size() > 0) { origin = order.getArtist().getAddresses().stream().findFirst().get(); } else { loggedUser = userRepository.findOneByLogin(SecurityUtils.getCurrentUserLogin()).get(); return ResponseEntity.badRequest() .headers( HeaderUtil.createFailureAlert( "purchaseOrder", "ArtistAddressNotFound", "The artist has no address.")) .body("{\"error\":\"ArtistAddressNotFound\"}"); } Address destination = order.getDestination(); Address billing = order.getBilling(); origin.setId(null); destination.setId(null); billing.setId(null); origin = addressRepository.save(origin); destination = addressRepository.save(destination); billing = addressRepository.save(billing); order.setAddress(origin); order.setDestination(destination); order.setBilling(billing); BigDecimal price = new BigDecimal(work.getPrice()); Long random = System.currentTimeMillis(); BigDecimal shippingCost = rateWebServiceClient.send( random.toString(), origin.getCountry().getCountryCode(), origin.getZipPostalCode(), destination.getCountry().getCountryCode(), destination.getZipPostalCode(), work.getHeight().toString(), work.getWidth().toString(), (work.getDepth() != null ? work.getDepth().toString() : "1"), work.getPrice().toString()); work.setShippingCost(shippingCost); order.setShippingCosts(shippingCost); BigDecimal total = price.add(shippingCost); order.setTotal(total); initializedOrders.add(order); } Iterator<PurchaseOrder> itInitialized = initializedOrders.iterator(); ArrayList<String> createdIds = new ArrayList<>(); while (itInitialized.hasNext()) { PurchaseOrder order = itInitialized.next(); PurchaseOrder saved = purchaseOrderRepository.save(order); result.add(saved); createdIds.add(saved.getId().toString()); concatId += "_" + saved.getId().toString(); ArtWorkPiece artwork = order.getArtWorkPiece(); loggedUser.getShoppingCart().remove(artwork); artwork.setCommercialState(CommercialState.Sold); artWorkPieceRepository.save(artwork); } // loggedUser.setShoppingCart(null); userRepository.save(loggedUser); String location = payPalResource.checkout(createdIds); ResponseEntity error = checkErrors(location); if (error != null) { return error; } return ResponseEntity.created(new URI("/api/purchaseOrders/" + concatId)) .headers(HeaderUtil.createEntityCreationAlert("purchaseOrder", concatId)) .body("{\"location\":\"" + location + "\"}"); }