agave-metadata/metadata-core/src/test/java/org/iplantc/service/metadata/managers/MetadataPermissionManagerIT.java
/**
     * Create a test entity persisted and available for lookup.
     *
     * @return a persisted instance of the entity
     */
Create a test entity persisted and available for lookup.
@return a persisted instance of the entity
Create a test entity persisted and available for lookup . @return a persisted instance of the entity
@Override
    public MetadataItem createEntity() {
        MetadataItem toAdd = null;
        try {
            toAdd = new MetadataItem();
            toAdd.setName(MetadataPermissionManagerIT.class.getName());
            toAdd.setValue(mapper.createObjectNode().put("testKey", "testValue"));
            toAdd.setOwner(TEST_USER);
            toAdd.setInternalUsername(TEST_USER);
            MetadataPermission readPermission = new MetadataPermission(TEST_SHARED_USER, PermissionType.READ);
            toAdd.getPermissions().addAll(List.of(readPermission));
            MetadataSearch search = new MetadataSearch(TEST_USER);
            addedItem = search.insertMetadataItem(toAdd);
        } catch (Exception e) {
            Assert.fail("Unable to create metadata item", e);
        }
        return addedItem;
    }
@ Override public MetadataItem createEntity ( ) { MetadataItem toAdd = null ; try { toAdd = new MetadataItem ( ) ; toAdd . setName ( MetadataPermissionManagerIT . class . getName ( ) ) ; toAdd . setValue ( mapper . createObjectNode ( ) . put ( "testKey" , "testValue" ) ) ; toAdd . setOwner ( TEST_USER ) ; toAdd . setInternalUsername ( TEST_USER ) ; MetadataPermission readPermission = new MetadataPermission ( TEST_SHARED_USER , PermissionType . READ ) ; toAdd . getPermissions ( ) . addAll ( List . of ( readPermission ) ) ; MetadataSearch search = new MetadataSearch ( TEST_USER ) ; addedItem = search . insertMetadataItem ( toAdd ) ; } catch ( Exception e ) { Assert . fail ( "Unable to create metadata item" , e ) ; } return addedItem ; }
Create a test entity persisted and available for lookup.
Create a test entity persisted and available for lookup .
//            addedItem = MetadataDao.getInstance().insert(toAdd); //            search.setMetadataItem(toAdd); //            MetadataDao inst = mock(MetadataDao.class); //            when(inst.insert(toAdd)).thenReturn(toAdd); //MetadataDao.getInstance().insert(entity);