@Test public void testConvertToProjectProperties3() throws IOException { Hudson hudson = createMock(Hudson.class); Mailer.DescriptorImpl descriptor = createMock(Mailer.DescriptorImpl.class); String mailerName = "hudson-tasks-Mailer"; expect(descriptor.getJsonSafeClassName()).andReturn(mailerName); expect(hudson.getDescriptorOrDie(Mailer.class)).andReturn(descriptor); mockStatic(Hudson.class); expect(Hudson.getInstance()).andReturn(hudson).anyTimes(); prepareJob(); DescribableList<Publisher, Descriptor<Publisher>> list = new DescribableList<Publisher, Descriptor<Publisher>>(); list.add(new Mailer()); Map<String, ExternalProjectProperty<Publisher>> map = DescribableListUtil.convertToProjectProperties(list, job); assertNotNull(map); assertEquals(map.size(), 1); assertNotNull(map.get(mailerName)); assertEquals(map.get(mailerName).getValue().getClass(), Mailer.class); }
public static <T extends Describable<T>, D extends Descriptor<T>> Map<String, ExternalProjectProperty<T>> convertToProjectProperties(DescribableList<T, D> describableList, Job owner) { Map<String, ExternalProjectProperty<T>> result = Maps.newConcurrentMap(); if (null != describableList) { for (Map.Entry<D, T> entry : describableList.toMap().entrySet()) { ExternalProjectProperty<T> property = new ExternalProjectProperty<T>(owner); String key = entry.getKey().getJsonSafeClassName(); property.setKey(key); property.setValue(entry.getValue()); result.put(key, property); } } return result; }
DescribableListUtil { public static <T extends Describable<T>, D extends Descriptor<T>> Map<String, ExternalProjectProperty<T>> convertToProjectProperties(DescribableList<T, D> describableList, Job owner) { Map<String, ExternalProjectProperty<T>> result = Maps.newConcurrentMap(); if (null != describableList) { for (Map.Entry<D, T> entry : describableList.toMap().entrySet()) { ExternalProjectProperty<T> property = new ExternalProjectProperty<T>(owner); String key = entry.getKey().getJsonSafeClassName(); property.setKey(key); property.setValue(entry.getValue()); result.put(key, property); } } return result; } }
DescribableListUtil { public static <T extends Describable<T>, D extends Descriptor<T>> Map<String, ExternalProjectProperty<T>> convertToProjectProperties(DescribableList<T, D> describableList, Job owner) { Map<String, ExternalProjectProperty<T>> result = Maps.newConcurrentMap(); if (null != describableList) { for (Map.Entry<D, T> entry : describableList.toMap().entrySet()) { ExternalProjectProperty<T> property = new ExternalProjectProperty<T>(owner); String key = entry.getKey().getJsonSafeClassName(); property.setKey(key); property.setValue(entry.getValue()); result.put(key, property); } } return result; } private  DescribableListUtil(); }
DescribableListUtil { public static <T extends Describable<T>, D extends Descriptor<T>> Map<String, ExternalProjectProperty<T>> convertToProjectProperties(DescribableList<T, D> describableList, Job owner) { Map<String, ExternalProjectProperty<T>> result = Maps.newConcurrentMap(); if (null != describableList) { for (Map.Entry<D, T> entry : describableList.toMap().entrySet()) { ExternalProjectProperty<T> property = new ExternalProjectProperty<T>(owner); String key = entry.getKey().getJsonSafeClassName(); property.setKey(key); property.setValue(entry.getValue()); result.put(key, property); } } return result; } private  DescribableListUtil(); static DescribableList<T, D> buildFromJson(
        Saveable owner,
        StaplerRequest req,
        JSONObject json,
        List<D> descriptors); static DescribableList<T, D> buildFromHetero(
        Saveable owner,
        StaplerRequest req, JSONObject formData,
        String key,
        Collection<D> descriptors); static Map<String, ExternalProjectProperty<T>> convertToProjectProperties(DescribableList<T, D> describableList, Job owner); static DescribableList<T, Descriptor<T>> convertToDescribableList(
        List<Descriptor<T>> descriptors, Job owner); @SuppressWarnings("unchecked") static DescribableList<T, D> convertToDescribableList(List<D> descriptors, Job owner, Class<P> propertyClass); }
DescribableListUtil { public static <T extends Describable<T>, D extends Descriptor<T>> Map<String, ExternalProjectProperty<T>> convertToProjectProperties(DescribableList<T, D> describableList, Job owner) { Map<String, ExternalProjectProperty<T>> result = Maps.newConcurrentMap(); if (null != describableList) { for (Map.Entry<D, T> entry : describableList.toMap().entrySet()) { ExternalProjectProperty<T> property = new ExternalProjectProperty<T>(owner); String key = entry.getKey().getJsonSafeClassName(); property.setKey(key); property.setValue(entry.getValue()); result.put(key, property); } } return result; } private  DescribableListUtil(); static DescribableList<T, D> buildFromJson(
        Saveable owner,
        StaplerRequest req,
        JSONObject json,
        List<D> descriptors); static DescribableList<T, D> buildFromHetero(
        Saveable owner,
        StaplerRequest req, JSONObject formData,
        String key,
        Collection<D> descriptors); static Map<String, ExternalProjectProperty<T>> convertToProjectProperties(DescribableList<T, D> describableList, Job owner); static DescribableList<T, Descriptor<T>> convertToDescribableList(
        List<Descriptor<T>> descriptors, Job owner); @SuppressWarnings("unchecked") static DescribableList<T, D> convertToDescribableList(List<D> descriptors, Job owner, Class<P> propertyClass);  }