@Test public void testShoudCreateResourceWhenNameAndDescriptorProvided() throws Exception { kerberosDescriptorResourceProvider = new KerberosDescriptorResourceProvider(kerberosDescriptorDAO, kerberosDescriptorFactory, Collections.<String>emptySet(), Collections.<Resource.Type, String>emptyMap(), null); EasyMock.expect(request.getProperties()) .andReturn(requestPropertySet(KERBEROS_DESCRIPTORS_KERBEROS_DESCRIPTOR_NAME, TEST_KERBEROS_DESCRIPTOR_NAME)) .times(3); EasyMock.expect(request.getRequestInfoProperties()) .andReturn(requestInfoPropertyMap(Request.REQUEST_INFO_BODY_PROPERTY, TEST_KERBEROS_DESCRIPTOR)) .times(3); EasyMock.expect(kerberosDescriptorFactory.createKerberosDescriptor(anyString(), anyString())) .andReturn(new KerberosDescriptorImpl(TEST_KERBEROS_DESCRIPTOR_NAME, TEST_KERBEROS_DESCRIPTOR)); Capture<KerberosDescriptorEntity> entityCapture = EasyMock.newCapture(); kerberosDescriptorDAO.create(capture(entityCapture)); EasyMock.replay(request, kerberosDescriptorFactory, kerberosDescriptorDAO); kerberosDescriptorResourceProvider.createResources(request); Assert.assertNotNull(entityCapture.getValue()); Assert.assertEquals("The resource name is invalid!", TEST_KERBEROS_DESCRIPTOR_NAME, entityCapture.getValue() .getName()); }
@Override public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException { String name = getNameFromRequest(request); String descriptor = getRawKerberosDescriptorFromRequest(request); KerberosDescriptor kerberosDescriptor = kerberosDescriptorFactory.createKerberosDescriptor(name, descriptor); kerberosDescriptorDAO.create(kerberosDescriptor.toEntity()); return getRequestStatus(null); }
KerberosDescriptorResourceProvider extends AbstractControllerResourceProvider { @Override public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException { String name = getNameFromRequest(request); String descriptor = getRawKerberosDescriptorFromRequest(request); KerberosDescriptor kerberosDescriptor = kerberosDescriptorFactory.createKerberosDescriptor(name, descriptor); kerberosDescriptorDAO.create(kerberosDescriptor.toEntity()); return getRequestStatus(null); } }
KerberosDescriptorResourceProvider extends AbstractControllerResourceProvider { @Override public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException { String name = getNameFromRequest(request); String descriptor = getRawKerberosDescriptorFromRequest(request); KerberosDescriptor kerberosDescriptor = kerberosDescriptorFactory.createKerberosDescriptor(name, descriptor); kerberosDescriptorDAO.create(kerberosDescriptor.toEntity()); return getRequestStatus(null); } @Inject  KerberosDescriptorResourceProvider(KerberosDescriptorDAO kerberosDescriptorDAO,
                                     KerberosDescriptorFactory kerberosDescriptorFactory,
                                     @Assisted Set<String> propertyIds,
                                     @Assisted Map<Resource.Type, String> keyPropertyIds,
                                     @Assisted AmbariManagementController managementController); }
KerberosDescriptorResourceProvider extends AbstractControllerResourceProvider { @Override public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException { String name = getNameFromRequest(request); String descriptor = getRawKerberosDescriptorFromRequest(request); KerberosDescriptor kerberosDescriptor = kerberosDescriptorFactory.createKerberosDescriptor(name, descriptor); kerberosDescriptorDAO.create(kerberosDescriptor.toEntity()); return getRequestStatus(null); } @Inject  KerberosDescriptorResourceProvider(KerberosDescriptorDAO kerberosDescriptorDAO,
                                     KerberosDescriptorFactory kerberosDescriptorFactory,
                                     @Assisted Set<String> propertyIds,
                                     @Assisted Map<Resource.Type, String> keyPropertyIds,
                                     @Assisted AmbariManagementController managementController); @Override Set<String> checkPropertyIds(Set<String> propertyIds); @Override RequestStatus createResources(Request request); @Override Set<Resource> getResources(Request request, Predicate predicate); @Override RequestStatus updateResources(Request request, Predicate predicate); @Override RequestStatus deleteResources(Request request, Predicate predicate); }
KerberosDescriptorResourceProvider extends AbstractControllerResourceProvider { @Override public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException { String name = getNameFromRequest(request); String descriptor = getRawKerberosDescriptorFromRequest(request); KerberosDescriptor kerberosDescriptor = kerberosDescriptorFactory.createKerberosDescriptor(name, descriptor); kerberosDescriptorDAO.create(kerberosDescriptor.toEntity()); return getRequestStatus(null); } @Inject  KerberosDescriptorResourceProvider(KerberosDescriptorDAO kerberosDescriptorDAO,
                                     KerberosDescriptorFactory kerberosDescriptorFactory,
                                     @Assisted Set<String> propertyIds,
                                     @Assisted Map<Resource.Type, String> keyPropertyIds,
                                     @Assisted AmbariManagementController managementController); @Override Set<String> checkPropertyIds(Set<String> propertyIds); @Override RequestStatus createResources(Request request); @Override Set<Resource> getResources(Request request, Predicate predicate); @Override RequestStatus updateResources(Request request, Predicate predicate); @Override RequestStatus deleteResources(Request request, Predicate predicate);  }