### Question:
SVNBranchConfigurationPropertyType extends AbstractPropertyType<SVNBranchConfigurationProperty> { @Override public boolean canEdit(ProjectEntity entity, SecurityService securityService) { return securityService.isProjectFunctionGranted(entity.projectId(), ProjectConfig.class) && propertyService.hasProperty( entity.getProject(), SVNProjectConfigurationPropertyType.class); } @Autowired  SVNBranchConfigurationPropertyType(SVNExtensionFeature extensionFeature, PropertyService propertyService, BuildSvnRevisionLinkService buildSvnRevisionLinkService, TagNameSvnRevisionLink tagNameSvnRevisionLink); @Override String getName(); @Override String getDescription(); @Override Set<ProjectEntityType> getSupportedEntityTypes(); @Override boolean canEdit(ProjectEntity entity, SecurityService securityService); @Override boolean canView(ProjectEntity entity, SecurityService securityService); @Override Form getEditionForm(ProjectEntity entity, SVNBranchConfigurationProperty value); @Override SVNBranchConfigurationProperty fromClient(JsonNode node); @Override SVNBranchConfigurationProperty fromStorage(JsonNode node); @Override String getSearchKey(SVNBranchConfigurationProperty value); @Override SVNBranchConfigurationProperty replaceValue(SVNBranchConfigurationProperty value, Function<String, String> replacementFunction);  }### Answer:
@Test public void not_editable_when_project_not_configured() { Project project = Project.of(new NameDescription("P", "Project")).withId(ID.of(1)); Branch branch = Branch.of(project, new NameDescription("B", "Branch")).withId(ID.of(1)); PropertyService propertiesService = mock(PropertyService.class); when(propertiesService.hasProperty(project, SVNProjectConfigurationPropertyType.class)).thenReturn(false); SecurityService securityService = mock(SecurityService.class); when(securityService.isProjectFunctionGranted(1, ProjectConfig.class)).thenReturn(true); BuildSvnRevisionLinkService buildSvnRevisionLinkService = mock(BuildSvnRevisionLinkService.class); TagNameSvnRevisionLink tagNameSvnRevisionLink = new TagNameSvnRevisionLink( mock(SVNService.class), mock(StructureService.class)); SVNBranchConfigurationPropertyType propertyType = new SVNBranchConfigurationPropertyType( new SVNExtensionFeature(new SCMExtensionFeature()), propertiesService, buildSvnRevisionLinkService, tagNameSvnRevisionLink ); assertFalse(propertyType.canEdit(branch, securityService)); }
@Test public void editable_when_project_configured() { Project project = Project.of(new NameDescription("P", "Project")).withId(ID.of(1)); Branch branch = Branch.of(project, new NameDescription("B", "Branch")).withId(ID.of(1)); PropertyService propertiesService = mock(PropertyService.class); when(propertiesService.hasProperty(project, SVNProjectConfigurationPropertyType.class)).thenReturn(true); SecurityService securityService = mock(SecurityService.class); when(securityService.isProjectFunctionGranted(1, ProjectConfig.class)).thenReturn(true); BuildSvnRevisionLinkService buildSvnRevisionLinkService = mock(BuildSvnRevisionLinkService.class); TagNameSvnRevisionLink tagNameSvnRevisionLink = new TagNameSvnRevisionLink( mock(SVNService.class), mock(StructureService.class)); SVNBranchConfigurationPropertyType propertyType = new SVNBranchConfigurationPropertyType( new SVNExtensionFeature(new SCMExtensionFeature()), propertiesService, buildSvnRevisionLinkService, tagNameSvnRevisionLink); assertTrue(propertyType.canEdit(branch, securityService)); }