<commit_before>/*
 *    Copyright 2012 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jj.resource;

import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.BDDMockito.given;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.file.Files;
import java.nio.file.Path;

import jj.Base;
import jj.configuration.resolution.Application;
import jj.configuration.resolution.MockApplication;
import jj.css.CssResource;
import jj.event.Publisher;
import jj.util.SHA1Helper;

import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

/**
 * @author jason
 *
 */
@RunWith(MockitoJUnitRunner.class)
public abstract class RealResourceBase {
	
	protected Path appPath;
	protected Application app;
	@Mock protected Publisher publisher;

	@Before
	public final void init() throws Exception {
		app = new MockApplication();
		appPath = Base.appPath();
		given(app.path()).willReturn(appPath);
	}
	
	protected <T extends Resource> T testResource(final T resource) throws Exception {
		
		if (resource instanceof FileResource) {
			testFileResource((FileResource)resource);
		} else {
			testNonFileResource(resource);
		}
		
		return resource;
	}
	
	private <T extends FileResource> T testFileResource(final T resource) throws Exception {
		// well this is weirdly ugly haha
		final Path path = resource.path();<commit_msg>was mocking something for no reason<commit_after>/*
 *    Copyright 2012 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package jj.resource;

import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.file.Files;
import java.nio.file.Path;

import jj.Base;
import jj.configuration.resolution.Application;
import jj.configuration.resolution.MockApplication;
import jj.css.CssResource;
import jj.event.Publisher;
import jj.util.SHA1Helper;

import org.hamcrest.Matchers;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

/**
 * @author jason
 *
 */
@RunWith(MockitoJUnitRunner.class)
public abstract class RealResourceBase {
	
	protected Path appPath;
	protected Application app;
	@Mock protected Publisher publisher;

	@Before
	public final void init() throws Exception {
		app = new MockApplication();
		appPath = Base.appPath();
	}
	
	protected <T extends Resource> T testResource(final T resource) throws Exception {
		
		if (resource instanceof FileResource) {
			testFileResource((FileResource)resource);
		} else {
			testNonFileResource(resource);
		}
		
		return resource;
	}
	
	private <T extends FileResource> T testFileResource(final T resource) throws Exception {
		// well this is weirdly ugly haha
		final Path path = resource.path();
{'fraction_non_alphanumeric': 0.08947487040793328, 'fraction_numerical': 0.004056795131845842, 'mean_word_length': 4.610619469026549, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4225725', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1270, 'n_words': 414}