@Test
    public void whenPackage() throws Exception {
      ApplicationPackage applicationPackage =
          new ApplicationPackage(ApplicationFeatureId.newPackage("com.mycompany"));

      final String str = applicationPackage.viewModelMemento();
      final ApplicationFeatureViewModel applicationFeatureVM2 = new ApplicationPackage();
      applicationFeatureVM2.viewModelInit(str);

      assertThat(applicationFeatureVM2.getType(), CoreMatchers.is(ApplicationFeatureType.PACKAGE));
      assertThat(applicationFeatureVM2.getPackageName(), is("com.mycompany"));
      assertThat(applicationFeatureVM2.getClassName(), is(nullValue()));
      assertThat(applicationFeatureVM2.getMemberName(), is(nullValue()));
    }
    @Test
    public void givenPackage_whenAddPackageAndClass() throws Exception {

      // given
      final ApplicationFeatureId applicationFeatureId =
          ApplicationFeatureId.newPackage("com.mycompany");
      final ApplicationFeatureId packageFeatureId =
          ApplicationFeatureId.newPackage("com.mycompany.flob");
      final ApplicationFeatureId classFeatureId =
          ApplicationFeatureId.newClass("com.mycompany.Bar");

      final ApplicationFeature applicationFeature = new ApplicationFeature(applicationFeatureId);

      applicationFeature.addToContents(packageFeatureId);
      applicationFeature.addToContents(classFeatureId);

      ApplicationPackage applicationFeatureVM = new ApplicationPackage(applicationFeatureId);
      applicationFeatureVM.applicationFeatureRepository = mockApplicationFeatureRepository;
      applicationFeatureVM.container = mockContainer;

      // then
      context.checking(
          new Expectations() {
            {
              allowing(mockApplicationFeatureRepository).findFeature(applicationFeatureId);
              will(returnValue(applicationFeature));

              oneOf(mockContainer)
                  .newViewModelInstance(
                      ApplicationPackage.class, packageFeatureId.asEncodedString());
              will(returnValue(new ApplicationPackage()));

              oneOf(mockContainer)
                  .newViewModelInstance(ApplicationClass.class, classFeatureId.asEncodedString());
              will(returnValue(new ApplicationClass()));
            }
          });

      // when
      final List<ApplicationFeatureViewModel> contents = applicationFeatureVM.getContents();

      // then
      assertThat(contents.size(), is(2));
    }