Search in sources :

Example 11 with LocalDate

use of java.time.LocalDate in project SmartCity-Market by TechnionYP5777.

the class UpdateProductPicturesEmployeeTest method updateIsNeededTest.

@Test
public void updateIsNeededTest() {
    try {
        LocalDate currentPicturesDate = PictureManager.getCurrentDate();
        Mockito.when(clientRequestHandler.sendRequestWithRespond((new CommandWrapper(w.getClientId(), CommandDescriptor.UPDATE_PRODUCTS_PICTURES, Serialization.serialize(currentPicturesDate))).serialize())).thenReturn(new CommandWrapper(ResultDescriptor.SM_OK, Serialization.serialize(encodedZipFile4Testing)).serialize());
    } catch (IOException ยข) {
        fail();
    }
    try {
        updateProductPicturesThread.start();
        updateProductPicturesThread.join();
    } catch (Exception e) {
        System.out.println(e + "");
        fail();
    }
}
Also used : CommandWrapper(ClientServerApi.CommandWrapper) IOException(java.io.IOException) LocalDate(java.time.LocalDate) IOException(java.io.IOException) Test(org.junit.Test)

Example 12 with LocalDate

use of java.time.LocalDate in project SmartCity-Market by TechnionYP5777.

the class PictureManager method checkIfMostUpdate.

public static boolean checkIfMostUpdate(LocalDate d) throws IOException {
    ObjectInputStream objectinputstream = null;
    LocalDate updatedDate = null;
    try {
        FileInputStream streamIn = new FileInputStream(GuiCommonDefs.productsPicturesPathLastUpdate);
        objectinputstream = new ObjectInputStream(streamIn);
        updatedDate = (LocalDate) objectinputstream.readObject();
    } catch (Exception e) {
        throw new IOException();
    } finally {
        if (objectinputstream != null)
            objectinputstream.close();
    }
    return updatedDate != null && d.compareTo(updatedDate) >= 0;
}
Also used : IOException(java.io.IOException) LocalDate(java.time.LocalDate) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) SMException(SMExceptions.SMException) ObjectInputStream(java.io.ObjectInputStream)

Example 13 with LocalDate

use of java.time.LocalDate in project SmartCity-Market by TechnionYP5777.

the class PictureManager method getCurrentDate.

public static LocalDate getCurrentDate() throws IOException {
    ObjectInputStream objectinputstream = null;
    LocalDate updatedDate = null;
    try {
        FileInputStream streamIn = new FileInputStream(GuiCommonDefs.productsPicturesPathLastUpdate);
        objectinputstream = new ObjectInputStream(streamIn);
        updatedDate = (LocalDate) objectinputstream.readObject();
    } catch (Exception e) {
        throw new IOException();
    } finally {
        if (objectinputstream != null)
            objectinputstream.close();
    }
    return updatedDate;
}
Also used : IOException(java.io.IOException) LocalDate(java.time.LocalDate) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) SMException(SMExceptions.SMException) ObjectInputStream(java.io.ObjectInputStream)

Example 14 with LocalDate

use of java.time.LocalDate in project SmartCity-Market by TechnionYP5777.

the class SQLJsonGenerator method CostumerProfileToJson.

/**
	 * convert customerProfile from ResultSet to Json representation of product
	 * 
	 * @param customer
	 *            - ResultSet of the customer profile. the
	 *            ResultSet need to point to the username to convert). this
	 *            object will point the next product after returning.
	 * @param customerIngredients
	 *            - ResultSet of the customer\s ingredients (assuming the
	 *            ResultSet ordered by username column) the ResultSet should
	 *            pointing the product to convert, if it has ingredients. if so,
	 *            this object will point the next customer (or after last line) after returning.
	 * @return
	 * @throws CriticalError
	 */
static String CostumerProfileToJson(ResultSet customer, ResultSet customerIngredients) throws CriticalError {
    HashSet<Ingredient> ingredients;
    try {
        //get customer username
        String customerUsername = getStringFromResultset(customer, CustomersTable.customerusernameCol);
        // get all customer ingredients
        ingredients = createIngredientsListForCustomer(customerUsername, customerIngredients);
        String customeraddress = getStringFromResultset(customer, CustomersTable.customerAddressCol), customerCity = getStringFromResultset(customer, CustomersTable.customerCityCol), customerEmail = getStringFromResultset(customer, CustomersTable.customerEmailCol), customerFirstname = getStringFromResultset(customer, CustomersTable.customerFirstnameCol), customerLastname = getStringFromResultset(customer, CustomersTable.customerLastnameCol), customerPhonenumber = getStringFromResultset(customer, CustomersTable.customerPhonenumberCol);
        LocalDate customerBirthdate = customer.getDate(CustomersTable.customerBirthdateCol.getColumnNameSQL()).toLocalDate();
        customer.next();
        return Serialization.serialize(new CustomerProfile(customerUsername, null, customerFirstname, customerLastname, customerPhonenumber, customerEmail, customerCity, customeraddress, customerBirthdate, ingredients, null));
    } catch (SQLException e) {
        throw new SQLDatabaseException.CriticalError();
    }
}
Also used : Ingredient(BasicCommonClasses.Ingredient) SQLException(java.sql.SQLException) CriticalError(SQLDatabase.SQLDatabaseException.CriticalError) CustomerProfile(BasicCommonClasses.CustomerProfile) LocalDate(java.time.LocalDate)

Example 15 with LocalDate

use of java.time.LocalDate in project SmartCity-Market by TechnionYP5777.

the class ManagePackagesTab method searchCodeButtonPressed.

@FXML
private void searchCodeButtonPressed(MouseEvent __) {
    try {
        LocalDate expirationDate = this.expirationDate != null ? this.expirationDate : datePickerForSmartCode.getValue();
        if (expirationDate == null)
            barcodeEntered(barcodeTextField.getText());
        else
            smartcodeEntered(new SmartCode(Long.parseLong(barcodeTextField.getText()), expirationDate));
        this.expirationDate = expirationDate;
    } catch (SMException e) {
        log.fatal(e);
        log.debug(StackTraceUtil.getStackTrace(e));
        e.showInfoToUser();
        return;
    }
    enableRunTheOperationButton();
}
Also used : SmartCode(BasicCommonClasses.SmartCode) SMException(SMExceptions.SMException) LocalDate(java.time.LocalDate) FXML(javafx.fxml.FXML)

Aggregations

LocalDate (java.time.LocalDate)1513 Test (org.junit.Test)472 Test (org.testng.annotations.Test)372 LocalDateTime (java.time.LocalDateTime)155 LocalTime (java.time.LocalTime)126 Date (java.util.Date)99 DateTimeFormatter (java.time.format.DateTimeFormatter)96 Ignore (org.junit.Ignore)94 ArrayList (java.util.ArrayList)87 BigDecimal (java.math.BigDecimal)69 Instant (java.time.Instant)56 ZonedDateTime (java.time.ZonedDateTime)55 Test (org.junit.jupiter.api.Test)54 List (java.util.List)50 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)46 HashMap (java.util.HashMap)44 Member (cz.metacentrum.perun.core.api.Member)41 ZoneId (java.time.ZoneId)40 TemporalField (java.time.temporal.TemporalField)40 Attribute (cz.metacentrum.perun.core.api.Attribute)39