Exemplo n.º 1
0
  @Test
  public void should_init_empty_entity_packages() throws Exception {
    doCallRealMethod().when(extractor).initEntityPackages(configMap);
    List<String> actual = extractor.initEntityPackages(configMap);

    assertThat(actual).isEmpty();
  }
Exemplo n.º 2
0
  @Test
  public void should_init_default_object_factory_mapper() throws Exception {
    doCallRealMethod().when(extractor).initObjectMapperFactory(configMap);
    ObjectMapperFactory actual = extractor.initObjectMapperFactory(configMap);

    assertThat(actual).isNotNull();

    ObjectMapper mapper = actual.getMapper(Integer.class);

    assertThat(mapper).isNotNull();
    assertThat(mapper.getSerializationConfig().getSerializationInclusion())
        .isEqualTo(Inclusion.NON_NULL);
    assertThat(
            mapper
                .getDeserializationConfig()
                .isEnabled(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES))
        .isFalse();
    Collection<AnnotationIntrospector> ais =
        mapper.getSerializationConfig().getAnnotationIntrospector().allIntrospectors();

    assertThat(ais).hasSize(2);
    Iterator<AnnotationIntrospector> iterator = ais.iterator();

    assertThat(iterator.next())
        .isInstanceOfAny(JacksonAnnotationIntrospector.class, JaxbAnnotationIntrospector.class);
    assertThat(iterator.next())
        .isInstanceOfAny(JacksonAnnotationIntrospector.class, JaxbAnnotationIntrospector.class);
  }
Exemplo n.º 3
0
  @Test
  public void should_init_forceCFCreation_to_default_value() throws Exception {
    doCallRealMethod().when(extractor).initForceCFCreation(configMap);
    boolean actual = extractor.initForceCFCreation(configMap);

    assertThat(actual).isFalse();
  }
Exemplo n.º 4
0
  @Test
  public void should_init_default_write_consistency_level() throws Exception {
    configMap.put(CONSISTENCY_LEVEL_WRITE_DEFAULT_PARAM, "LOCAL_QUORUM");

    doCallRealMethod().when(extractor).initDefaultWriteConsistencyLevel(configMap);
    assertThat(extractor.initDefaultWriteConsistencyLevel(configMap)).isEqualTo(LOCAL_QUORUM);
  }
Exemplo n.º 5
0
  @Test
  public void should_init_default_read_consistency_level() throws Exception {
    configMap.put(CONSISTENCY_LEVEL_READ_DEFAULT_PARAM, "ONE");

    doCallRealMethod().when(extractor).initDefaultReadConsistencyLevel(configMap);
    assertThat(extractor.initDefaultReadConsistencyLevel(configMap)).isEqualTo(ONE);
  }
Exemplo n.º 6
0
  @Test
  public void should_return_empty_consistency_map_when_no_parameter() throws Exception {
    doCallRealMethod().when(extractor).initWriteConsistencyMap(configMap);

    Map<String, ConsistencyLevel> consistencyMap = extractor.initWriteConsistencyMap(configMap);

    assertThat(consistencyMap).isEmpty();
  }
Exemplo n.º 7
0
  @Test
  public void should_init_forceCFCreation() throws Exception {
    configMap.put(FORCE_CF_CREATION_PARAM, true);

    doCallRealMethod().when(extractor).initForceCFCreation(configMap);
    boolean actual = extractor.initForceCFCreation(configMap);

    assertThat(actual).isTrue();
  }
Exemplo n.º 8
0
  @Test
  public void should_init_object_mapper_factory() throws Exception {
    configMap.put(OBJECT_MAPPER_FACTORY_PARAM, factory);

    doCallRealMethod().when(extractor).initObjectMapperFactory(configMap);
    ObjectMapperFactory actual = extractor.initObjectMapperFactory(configMap);

    assertThat(actual).isSameAs(factory);
  }
Exemplo n.º 9
0
  @Test
  public void should_init_entity_packages() throws Exception {
    configMap.put(ENTITY_PACKAGES_PARAM, "my.package.entity,another.package.entity,third.package");

    doCallRealMethod().when(extractor).initEntityPackages(configMap);
    List<String> actual = extractor.initEntityPackages(configMap);

    assertThat(actual)
        .containsExactly("my.package.entity", "another.package.entity", "third.package");
  }
Exemplo n.º 10
0
  @Test
  public void should_return_empty_consistency_map_when_empty_map_parameter() throws Exception {
    configMap.put(CONSISTENCY_LEVEL_WRITE_MAP_PARAM, new HashMap<String, String>());

    doCallRealMethod().when(extractor).initWriteConsistencyMap(configMap);

    Map<String, ConsistencyLevel> consistencyMap = extractor.initWriteConsistencyMap(configMap);

    assertThat(consistencyMap).isEmpty();
  }
Exemplo n.º 11
0
  @Test
  public void should_exception_when_invalid_consistency_level() throws Exception {
    configMap.put(CONSISTENCY_LEVEL_READ_DEFAULT_PARAM, "wrong_value");

    exception.expect(IllegalArgumentException.class);
    exception.expectMessage("'wrong_value' is not a valid Consistency Level");

    doCallRealMethod().when(extractor).initDefaultReadConsistencyLevel(configMap);
    extractor.initDefaultReadConsistencyLevel(configMap);
  }
Exemplo n.º 12
0
  @Test
  public void should_init_object_mapper_factory_from_mapper() throws Exception {
    configMap.put(OBJECT_MAPPER_PARAM, mapper);

    doCallRealMethod().when(extractor).initObjectMapperFactory(configMap);
    ObjectMapperFactory actual = extractor.initObjectMapperFactory(configMap);

    assertThat(actual).isNotNull();
    assertThat(actual.getMapper(Long.class)).isSameAs(mapper);
  }
Exemplo n.º 13
0
  @Test
  public void should_init_write_consistency_level_map() throws Exception {
    configMap.put(
        CONSISTENCY_LEVEL_WRITE_MAP_PARAM, ImmutableMap.of("cf1", "THREE", "cf2", "EACH_QUORUM"));

    doCallRealMethod().when(extractor).initWriteConsistencyMap(configMap);
    Map<String, ConsistencyLevel> consistencyMap = extractor.initWriteConsistencyMap(configMap);

    assertThat(consistencyMap.get("cf1")).isEqualTo(ConsistencyLevel.THREE);
    assertThat(consistencyMap.get("cf2")).isEqualTo(ConsistencyLevel.EACH_QUORUM);
  }
Exemplo n.º 14
0
  @Test
  public void should_init_read_consistency_level_map() throws Exception {
    configMap.put(
        CONSISTENCY_LEVEL_READ_MAP_PARAM, ImmutableMap.of("cf1", "ONE", "cf2", "LOCAL_QUORUM"));

    doCallRealMethod().when(extractor).initReadConsistencyMap(configMap);
    Map<String, ConsistencyLevel> consistencyMap = extractor.initReadConsistencyMap(configMap);

    assertThat(consistencyMap.get("cf1")).isEqualTo(ConsistencyLevel.ONE);
    assertThat(consistencyMap.get("cf2")).isEqualTo(ConsistencyLevel.LOCAL_QUORUM);
  }
Exemplo n.º 15
0
 @Test
 public void should_return_default_one_level_when_no_parameter() throws Exception {
   doCallRealMethod().when(extractor).initDefaultReadConsistencyLevel(configMap);
   assertThat(extractor.initDefaultReadConsistencyLevel(configMap)).isEqualTo(ONE);
 }