Search in sources :

Example 16 with LocalDate

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

the class UpdateProductPicturesCustomerTest method updateIsNotNeededTest.

@Test
public void updateIsNotNeededTest() {
    try {
        LocalDate currentPicturesDate = PictureManager.getCurrentDate();
        Mockito.when(clientRequestHandler.sendRequestWithRespond((new CommandWrapper(c.getId(), CommandDescriptor.UPDATE_PRODUCTS_PICTURES, Serialization.serialize(currentPicturesDate))).serialize())).thenReturn(new CommandWrapper(ResultDescriptor.SM_NO_UPDATE_NEEDED, Serialization.serialize(null)).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 17 with LocalDate

use of java.time.LocalDate in project Synthese_2BIN by TheYoungSensei.

the class ListeTarifs method deserialize.

@SuppressWarnings("unchecked")
public static boolean deserialize() {
    Assembly.getInstance().getListeTarifs();
    Path p = FileSystems.getDefault().getPath(ListeTarifs.NOM_FICHIER);
    try (InputStream in = Files.newInputStream(p);
        ObjectInputStream o = new ObjectInputStream(in)) {
        Assembly.getInstance().getListeTarifs().tarifs = (TreeMap<LocalDate, Tarif>) o.readObject();
        return true;
    } catch (IOException | ClassNotFoundException e) {
        e.printStackTrace();
        return false;
    }
}
Also used : Path(java.nio.file.Path) ObjectInputStream(java.io.ObjectInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) LocalDate(java.time.LocalDate) ObjectInputStream(java.io.ObjectInputStream)

Example 18 with LocalDate

use of java.time.LocalDate in project Synthese_2BIN by TheYoungSensei.

the class GestionEncheres method fournirEncherisseurDuJour.

// renvoie un ensemble vide s'il n'y a pas d'enchere
public Set<Utilisateur> fournirEncherisseurDuJour() {
    LocalDate aujourdhui = LocalDate.now();
    Set<Utilisateur> encherisseurs = new HashSet<Utilisateur>();
    SortedSet<Enchere> enchereDuJour = encheres.get(aujourdhui);
    if (enchereDuJour == null)
        return encherisseurs;
    enchereDuJour.forEach((e) -> encherisseurs.add(e.getEncherisseur()));
    // déjà cloné dans Enchère
    return encherisseurs;
}
Also used : Utilisateur(domaine.Utilisateur) Enchere(domaine.Enchere) LocalDate(java.time.LocalDate) HashSet(java.util.HashSet)

Example 19 with LocalDate

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

the class ProductPackageTest method ProductPackageTestMethod.

@Test
public void ProductPackageTestMethod() {
    LocalDate ld = LocalDate.of(2016, 12, 11);
    SmartCode sc = new SmartCode(123, ld);
    Location lo = new Location(1, 1, PlaceInMarket.WAREHOUSE);
    ProductPackage pp = new ProductPackage(sc, 2, lo);
    if (!sc.equals(pp.getSmartCode()) || pp.getAmount() != 2 || !lo.equals(pp.getLocation()))
        fail();
    sc.setBarcode(111);
    lo.setX(2);
    pp.setSmartCode(sc);
    pp.setAmount(1);
    pp.setLocation(lo);
    if (!sc.equals(pp.getSmartCode()) || pp.getAmount() != 1 || !lo.equals(pp.getLocation()))
        fail();
    LocalDate ld2 = LocalDate.of(2015, 12, 12);
    SmartCode sc2 = new SmartCode(111, ld2);
    ProductPackage pp2 = new ProductPackage(sc2, 1, lo);
    if (pp2.equals(pp))
        fail();
    sc2.setExpirationDate(sc.getExpirationDate());
    pp.setSmartCode(sc2);
    if (!pp2.equals(pp))
        fail();
}
Also used : SmartCode(BasicCommonClasses.SmartCode) ProductPackage(BasicCommonClasses.ProductPackage) LocalDate(java.time.LocalDate) Location(BasicCommonClasses.Location) Test(org.junit.Test)

Example 20 with LocalDate

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

the class SmartCodeTest method SmartCodeTestMethod.

@Test
public void SmartCodeTestMethod() {
    LocalDate ld = LocalDate.of(2016, 12, 11);
    SmartCode sc = new SmartCode(123, ld);
    if (sc.getBarcode() != 123 || !sc.getExpirationDate().equals(ld))
        fail();
    sc.setBarcode(111);
    ld.plusDays(1);
    sc.setExpirationDate(ld);
    if (sc.getBarcode() != 111 || !sc.getExpirationDate().equals(ld))
        fail();
    LocalDate ld2 = LocalDate.of(2015, 12, 12);
    SmartCode sc2 = new SmartCode(111, ld2);
    if (sc2.equals(sc))
        fail();
    sc2.setExpirationDate(sc.getExpirationDate());
    if (!sc2.equals(sc))
        fail();
}
Also used : SmartCode(BasicCommonClasses.SmartCode) LocalDate(java.time.LocalDate) Test(org.junit.Test)

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