@Test public void whenClass() throws Exception { ApplicationClass applicationClass = new ApplicationClass(ApplicationFeatureId.newClass("com.mycompany.Bar")); final String str = applicationClass.viewModelMemento(); final ApplicationFeatureViewModel applicationFeatureVM2 = new ApplicationClass(); applicationFeatureVM2.viewModelInit(str); assertThat(applicationFeatureVM2.getType(), is(ApplicationFeatureType.CLASS)); assertThat(applicationFeatureVM2.getPackageName(), is("com.mycompany")); assertThat(applicationFeatureVM2.getClassName(), is("Bar")); assertThat(applicationFeatureVM2.getMemberName(), is(nullValue())); }
@Test public void whenMember() throws Exception { ApplicationClassProperty applicationClassProperty = new ApplicationClassProperty(ApplicationFeatureId.newMember("com.mycompany.Bar", "foo")); final String str = applicationClassProperty.viewModelMemento(); final ApplicationFeatureViewModel applicationFeatureVM2 = new ApplicationClassProperty(); applicationFeatureVM2.viewModelInit(str); assertThat(applicationFeatureVM2.getType(), is(ApplicationFeatureType.MEMBER)); assertThat(applicationFeatureVM2.getPackageName(), is("com.mycompany")); assertThat(applicationFeatureVM2.getClassName(), is("Bar")); assertThat(applicationFeatureVM2.getMemberName(), is("foo")); }
@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())); }