/** Tests populateDTO. */
  @Test
  public void testPopulateDTO() {
    final boolean storeVisible = false;
    final int categoryOrder = 1;
    final String categoryCode = "categoryCode";
    final String categoryTypeCode = "categoryTypeCode";

    final CategoryDTO categoryDto = new CategoryDTO();

    final Catalog mockCatalog = context.mock(Catalog.class);
    final Category mockCategory = context.mock(Category.class);
    final CategoryType mockCategoryType = context.mock(CategoryType.class);
    final Category mockParentCategory = context.mock(Category.class, "parent category");

    context.checking(
        new Expectations() {
          {
            oneOf(mockCategory).getCatalog();
            will(returnValue(mockCatalog));
            oneOf(mockCategory).getParent();
            will(returnValue(mockParentCategory));
            oneOf(mockCategory).getCode();
            will(returnValue(categoryCode));
            oneOf(mockCategory).getCategoryType();
            will(returnValue(mockCategoryType));
            oneOf(mockCategory).getOrdering();
            will(returnValue(categoryOrder));
            oneOf(mockCategory).isHidden();
            will(returnValue(!storeVisible));
            oneOf(mockCategory).getStartDate();
            will(returnValue(START_DATE));
            oneOf(mockCategory).getEndDate();
            will(returnValue(END_DATE));

            oneOf(mockCatalog).getCode();
            will(returnValue(CATALOG_CODE));
            oneOf(mockCategoryType).getName();
            will(returnValue(categoryTypeCode));
            oneOf(mockParentCategory).getCode();
            will(returnValue(PARENT_CATEGORY_CODE));
          }
        });

    categoryAdapter =
        new CategoryAdapter() {
          @Override
          void populateDtoNameValues(final Category category, final CategoryDTO categoryDTO) {
            assertNotNull(category);
            categoryDTO.setNameValues(Arrays.asList(DISPLAY_VALUE_EN_LOCALE));
          }

          @Override
          void populateNestedDto(final Category category, final CategoryDTO categoryDto) {
            assertNotNull(category);
            assertNotNull(categoryDto);
            categoryDto.setAttributeGroupDTO(new AttributeGroupDTO());
            categoryDto.setSeoDto(new SeoDTO());
          }
        };
    categoryAdapter.setElasticPath(mockElasticPath);
    categoryAdapter.setCachingService(mockCachingService);
    categoryAdapter.populateDTO(mockCategory, categoryDto);

    assertEquals(categoryCode, categoryDto.getCategoryCode());
    assertEquals(categoryOrder, categoryDto.getOrder());
    assertEquals(CATALOG_CODE, categoryDto.getCatalogCode());
    assertEquals(PARENT_CATEGORY_CODE, categoryDto.getParentCategoryCode());
    assertEquals(categoryTypeCode, categoryDto.getCategoryType());

    final CategoryAvailabilityDTO categoryAvailabilityDTO =
        categoryDto.getCategoryAvailabilityDTO();
    assertEquals(storeVisible, categoryAvailabilityDTO.isStoreVisible());
    assertEquals(START_DATE, categoryAvailabilityDTO.getStartDate());
    assertEquals(END_DATE, categoryAvailabilityDTO.getEndDate());

    assertNotNull(categoryDto.getAttributeGroupDTO());
    assertNotNull(categoryDto.getSeoDto());
  }