コード例 #1
0
  @Test
  public void annuSetCityTest() {

    final Lang theLang = Factories.LANG.findByIsoCode("fr-FR");
    final TimezoneData inTimeZone = TimezoneData.findByJavaId("Europe/Paris");
    final CountryData inCountry = CountryData.getDefaultCountryByJavaId(CityTest.SUISSE, theLang);
    final User theUser =
        Factories.USER.createNewUser(
            "*****@*****.**",
            "aa",
            theLang,
            inCountry.getPaysCode(),
            "inFirstName",
            "inLastName",
            inTimeZone.getId());

    // 1ere ville 1er pays
    theUser.getAnnu().setCity(CityTest.LAUSANNE);
    City theCity = theUser.getAnnu().getCity();
    final Long idVille1 = theCity.getId();
    Assert.assertEquals(CityTest.LAUSANNE, theUser.getAnnu().getAnnu_city());
    Assert.assertEquals(CityTest.LAUSANNE, theCity.getName());

    // 2eme ville 1er pays
    theUser.getAnnu().setCity(CityTest.ZURICH);
    theCity = theUser.getAnnu().getCity();
    Assert.assertEquals(CityTest.ZURICH, theUser.getAnnu().getAnnu_city());
    Assert.assertEquals(CityTest.ZURICH, theCity.getName());

    theUser.getAnnu().setCity(CityTest.LAUSANNE);
    theCity = theUser.getAnnu().getCity();
    Assert.assertEquals(CityTest.LAUSANNE, theUser.getAnnu().getAnnu_city());
    Assert.assertEquals(CityTest.LAUSANNE, theCity.getName());
    Assert.assertEquals(idVille1, theCity.getId());

    // 1ere ville 2em pays
    theUser.getAnnu().setAddress("CA", "123-67");
    theUser.getAnnu().setCity(CityTest.LAUSANNE);
    theCity = theUser.getAnnu().getCity();

    Assert.assertEquals(CityTest.LAUSANNE, theUser.getAnnu().getAnnu_city());
    Assert.assertEquals(CityTest.LAUSANNE, theCity.getName());
    Assert.assertEquals(theUser.getAnnu().getAnnu_country(), theCity.getCountryCode());
    Assert.assertTrue(!(idVille1 == theCity.getId()));
  }
コード例 #2
0
  @Override
  public void checkSettings(VObjectData object, Map<String, Object> settings)
      throws InvalidSettingException, MissingSettingException {
    final Object source = settings.get(AirHandler.SOURCE_SETTING);
    final Object language = settings.get(AirHandler.LANGUAGE_SETTING);

    if ((source == null) || (language == null)) {
      throw new MissingSettingException(
          source == null ? AirHandler.SOURCE_SETTING : AirHandler.LANGUAGE_SETTING);
    }

    if (Factories.LANG.findByIsoCode(language.toString()) == null) {
      throw new InvalidSettingException(AirHandler.LANGUAGE_SETTING, language.toString());
    }

    if (!AirHandler.AIR_SOURCE.matcher(source.toString()).matches()
        || (Factories.SOURCE.findByPath(source.toString()) == null)) {
      throw new InvalidSettingException(AirHandler.SOURCE_SETTING, source.toString());
    }
  }