Esempio n. 1
0
  private void mockLookups() {
    LookupDto lookup =
        new LookupDto(
            TestDataService.LOOKUP_1_NAME,
            true,
            true,
            asList(FieldTestHelper.lookupFieldDto(1L, "strField")),
            true,
            "singleObject",
            asList("strField"));
    when(entityService.getLookupByName(ENTITY_ID, TestDataService.LOOKUP_1_NAME))
        .thenReturn(lookup);
    Map<String, FieldDto> mapping = new HashMap<>();
    mapping.put(
        "strField",
        FieldTestHelper.fieldDto(
            1L, "strField", String.class.getName(), "String field", "Default"));
    when(entityService.getLookupFieldsMapping(ENTITY_ID, TestDataService.LOOKUP_1_NAME))
        .thenReturn(mapping);

    lookup =
        new LookupDto(
            TestDataService.LOOKUP_2_NAME,
            false,
            true,
            asList(FieldTestHelper.lookupFieldDto(1L, "strField")),
            false,
            "multiObject",
            asList("strField"));
    when(entityService.getLookupByName(ENTITY_ID, TestDataService.LOOKUP_2_NAME))
        .thenReturn(lookup);
    when(entityService.getLookupFieldsMapping(ENTITY_ID, TestDataService.LOOKUP_2_NAME))
        .thenReturn(mapping);

    lookup =
        new LookupDto(
            TestDataService.NULL_EXPECTING_LOOKUP_NAME,
            false,
            true,
            asList(FieldTestHelper.lookupFieldDto(3L, "dtField")),
            false,
            "nullParamExpected",
            asList("dtField"));
    when(entityService.getLookupByName(ENTITY_ID, TestDataService.NULL_EXPECTING_LOOKUP_NAME))
        .thenReturn(lookup);
    mapping = new HashMap<>();
    mapping.put(
        "dtField",
        FieldTestHelper.fieldDto(3L, "dtField", DateTime.class.getName(), "DateTime field", null));
    when(entityService.getLookupFieldsMapping(
            ENTITY_ID, TestDataService.NULL_EXPECTING_LOOKUP_NAME))
        .thenReturn(mapping);
  }
Esempio n. 2
0
 private LookupDto getLookupByName(Long entityId, String lookupName) {
   LookupDto lookup = entityService.getLookupByName(entityId, lookupName);
   if (lookup == null) {
     throw new LookupNotFoundException(entityId, lookupName);
   }
   return lookup;
 }