### Question:
ProfileService { @Inject public ProfileService(CConfiguration cConf, MetricsSystemClient metricsSystemClient, TransactionRunner transactionRunner) { this.cConf = cConf; this.metricsSystemClient = metricsSystemClient; this.transactionRunner = transactionRunner; } @Inject  ProfileService(CConfiguration cConf,
                        MetricsSystemClient metricsSystemClient,
                        TransactionRunner transactionRunner); Profile getProfile(ProfileId profileId); Profile getProfile(ProfileId profileId, Map<String, String> overrides); List<Profile> getProfiles(NamespaceId namespaceId, boolean includeSystem); void saveProfile(ProfileId profileId, Profile profile); void createIfNotExists(ProfileId profileId, Profile profile); void deleteProfile(ProfileId profileId); void deleteAllProfiles(NamespaceId namespaceId); @VisibleForTesting void clear(); void enableProfile(ProfileId profileId); void disableProfile(ProfileId profileId); Set<EntityId> getProfileAssignments(ProfileId profileId); void addProfileAssignment(ProfileId profileId,
                                   EntityId entityId); void removeProfileAssignment(ProfileId profileId, EntityId entityId);  }### Answer:
@Test public void testProfileService() throws Exception { try { profileService.getProfile(NamespaceId.DEFAULT.profile("nonExisting")); Assert.fail(); } catch (NotFoundException e) { } try { profileService.deleteProfile(NamespaceId.DEFAULT.profile("nonExisting")); Assert.fail(); } catch (NotFoundException e) { } ProfileId profileId = NamespaceId.DEFAULT.profile("MyProfile"); Profile expected = new Profile("MyProfile", "label", "my profile for testing", new ProvisionerInfo("defaultProvisioner", PROPERTY_SUMMARIES)); profileService.saveProfile(profileId, expected); Assert.assertEquals(expected, profileService.getProfile(profileId)); expected = new Profile("MyProfile", "label", "my 2nd profile for updating", new ProvisionerInfo("anotherProvisioner", Collections.emptyList())); profileService.saveProfile(profileId, expected); Assert.assertEquals(expected, profileService.getProfile(profileId)); ProfileId profileId2 = NamespaceId.DEFAULT.profile("MyProfile2"); Profile profile2 = new Profile("MyProfile2", "label", "my 2nd profile for testing", new ProvisionerInfo("anotherProvisioner", PROPERTY_SUMMARIES)); profileService.saveProfile(profileId2, profile2); profileService.saveProfile(ProfileId.NATIVE, Profile.NATIVE); List<Profile> profiles = ImmutableList.of(expected, profile2, Profile.NATIVE); Assert.assertEquals(profiles, profileService.getProfiles(NamespaceId.DEFAULT, true)); Assert.assertEquals(ProfileStatus.ENABLED, profileService.getProfile(profileId).getStatus()); Assert.assertEquals(ProfileStatus.ENABLED, profileService.getProfile(profileId2).getStatus()); try { profileService.enableProfile(profileId); Assert.fail(); } catch (ProfileConflictException e) { } profileService.disableProfile(profileId); Assert.assertEquals(ProfileStatus.DISABLED, profileService.getProfile(profileId).getStatus()); try { profileService.disableProfile(profileId); Assert.fail(); } catch (ProfileConflictException e) { } profileService.enableProfile(profileId); Assert.assertEquals(ProfileStatus.ENABLED, profileService.getProfile(profileId).getStatus()); try { profileService.deleteProfile(profileId2); Assert.fail(); } catch (ProfileConflictException e) { } profileService.disableProfile(profileId2); profileService.deleteProfile(profileId2); Assert.assertEquals(ImmutableList.of(expected), profileService.getProfiles(NamespaceId.DEFAULT, false)); profileService.saveProfile(profileId2, profile2); profileService.disableProfile(profileId); profileService.disableProfile(profileId2); profileService.deleteAllProfiles(NamespaceId.DEFAULT); Assert.assertEquals(Collections.EMPTY_LIST, profileService.getProfiles(NamespaceId.DEFAULT, false)); try { profileService.enableProfile(profileId); Assert.fail(); } catch (NotFoundException e) { } try { profileService.disableProfile(profileId); Assert.fail(); } catch (NotFoundException e) { } }